[Python-checkins] hooks: parameterize the allowed branches so the Jython repo can reuse this hook
philip.jenvey
python-checkins at python.org
Tue Apr 19 01:48:47 CEST 2011
http://hg.python.org/hooks/rev/24eafedae830
changeset: 71:24eafedae830
user: Philip Jenvey <pjenvey at underboss.org>
date: Mon Apr 18 16:47:54 2011 -0700
summary:
parameterize the allowed branches so the Jython repo can reuse this hook
files:
checkbranch.py | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/checkbranch.py b/checkbranch.py
--- a/checkbranch.py
+++ b/checkbranch.py
@@ -7,6 +7,9 @@
[hooks]
pretxnchangegroup.checkbranch = python:/home/hg/repos/hooks/checkbranch.py:hook
+
+[checkbranch]
+allow-branches = default, 3.2, 3.1, 2.7, 2.6, 2.5
"""
from mercurial.node import bin
@@ -14,6 +17,11 @@
def hook(ui, repo, node, **kwargs):
+ branches = ui.configlist('checkbranch', 'allow-branches')
+ if not branches:
+ print 'checkbranch: No branches are configured'
+ return False
+
n = bin(node)
start = repo.changelog.rev(n)
end = len(repo.changelog)
@@ -22,7 +30,7 @@
n = repo.changelog.node(rev)
ctx = repo[n]
branch = ctx.branch()
- if branch not in ('default', '3.2', '3.1', '2.7', '2.6', '2.5'):
+ if branch not in branches:
ui.warn(' - changeset %s on disallowed branch %r!\n'
% (ctx, branch))
failed = True
--
Repository URL: http://hg.python.org/hooks
More information about the Python-checkins
mailing list