summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruce Williams <bruce@codefluency.com>2010-03-13 17:32:17 -0800
committerBruce Williams <bruce@codefluency.com>2010-03-13 17:32:17 -0800
commitc714947908b69c538ea9d050d4375e2b3f19e7ac (patch)
tree1a464a8d7534e43e30d09dd914cbf231f1a29601 /lib
parent6adc8745c6565391f5da534306c3ec206da9dc21 (diff)
downloadpuppet-vcsrepo-c714947908b69c538ea9d050d4375e2b3f19e7ac.tar.gz
puppet-vcsrepo-c714947908b69c538ea9d050d4375e2b3f19e7ac.tar.bz2
Support Mercurial tags, restructure examples
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/vcsrepo/hg.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/puppet/provider/vcsrepo/hg.rb b/lib/puppet/provider/vcsrepo/hg.rb
index 7263b4f..928049f 100644
--- a/lib/puppet/provider/vcsrepo/hg.rb
+++ b/lib/puppet/provider/vcsrepo/hg.rb
@@ -24,7 +24,24 @@ Puppet::Type.type(:vcsrepo).provide(:hg, :parent => Puppet::Provider::Vcsrepo) d
def revision
at_path do
- hg('parents')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1]
+ current = hg('parents')[/^changeset:\s+(?:-?\d+):(\S+)/m, 1]
+ desired = @resource.value(:revision)
+ if current == desired
+ current
+ else
+ mapped = hg('tags')[/^#{Regexp.quote(desired)}\s+\d+:(\S+)/m, 1]
+ if mapped
+ # A tag, return that tag if it maps to the current nodeid
+ if current == mapped
+ desired
+ else
+ current
+ end
+ else
+ # Use the current nodeid
+ current
+ end
+ end
end
end