add definitions for latest{,?} in hg provider
authorAaron Bull Schaefer <aaron@elasticdog.com>
Tue, 14 Dec 2010 17:42:30 +0000 (01:42 +0800)
committerJames Turnbull <james@lovedthanlost.net>
Mon, 27 Dec 2010 07:47:00 +0000 (15:47 +0800)
lib/puppet/provider/vcsrepo/hg.rb

index 10f99b9..0a2e5b7 100644 (file)
@@ -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]