From c0023928719024e346f5d3c03ef0f112db02f898 Mon Sep 17 00:00:00 2001 From: Aaron Bull Schaefer Date: Wed, 15 Dec 2010 01:42:30 +0800 Subject: add definitions for latest{,?} in hg provider --- lib/puppet/provider/vcsrepo/hg.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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] -- cgit v1.2.3