summaryrefslogtreecommitdiff
path: root/lib/puppet/provider/vcsrepo/hg.rb
diff options
context:
space:
mode:
authorAaron Bull Schaefer <aaron@elasticdog.com>2010-12-15 01:42:30 +0800
committerJames Turnbull <james@lovedthanlost.net>2010-12-27 15:47:00 +0800
commitc0023928719024e346f5d3c03ef0f112db02f898 (patch)
tree82c22826455661643299d18af1939c0b4981c7d6 /lib/puppet/provider/vcsrepo/hg.rb
parentca531df00f99df2e77300a08f5705d51e7544e94 (diff)
add definitions for latest{,?} in hg provider
Diffstat (limited to 'lib/puppet/provider/vcsrepo/hg.rb')
-rw-r--r--lib/puppet/provider/vcsrepo/hg.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb
index 10f99b9..0a2e5b7 100644
--- a/lib/puppet/provider/vcsrepo/hg.rb
+++ b/lib/puppet/provider/vcsrepo/hg.rb
@@ -27,6 +27,23 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d
FileUtils.rm_rf(@resource.value(:path))
end
+ def latest?
+ at_path do
+ return self.revision == self.latest
+ end
+ end
+
+ def latest
+ at_path do
+ begin
+ hg('incoming', '--branch', '.', '--newest-first', '--limit', '1')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1]
+ rescue Puppet::ExecutionFailure
+ # If there are no new changesets, return the current nodeid
+ self.revision
+ end
+ end
+ end
+
def revision
at_path do
current = hg('parents')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1]