[Python-checkins] hooks: Fix checkbranch hook
antoine.pitrou
python-checkins at python.org
Sat Feb 26 21:25:04 CET 2011
antoine.pitrou pushed 2f045ec0b6c6 to hooks:
http://hg.python.org/hooks/rev/2f045ec0b6c6
changeset: 30:2f045ec0b6c6
tag: tip
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Feb 26 21:25:02 2011 +0100
summary:
Fix checkbranch hook
files:
checkbranch.py
diff --git a/checkbranch.py b/checkbranch.py
--- a/checkbranch.py
+++ b/checkbranch.py
@@ -6,18 +6,29 @@
following in your hgrc file.
[hooks]
-pretxncommit.checkbranch = python:/home/hg/repos/hooks/checkbranch.py:hook
+pretxnchangegroup.checkbranch = python:/home/hg/repos/hooks/checkbranch.py:hook
"""
+from mercurial.node import bin
from mercurial import util
def hook(ui, repo, node, **kwargs):
- ctx = repo[node]
- branch = ctx.branch()
- if branch in ('trunk', 'legacy-trunk',
- '2.0', '2.1', '2.2', '2.3', '2.4', '3.0'):
- raise util.Abort('changeset %s on disallowed branch %r, '
- 'please strip your changeset and '
- 're-do it on another branch '
- % (ctx, branch))
+ n = bin(node)
+ start = repo.changelog.rev(n)
+ end = len(repo.changelog)
+ failed = False
+ for rev in xrange(start, end):
+ n = repo.changelog.node(rev)
+ ctx = repo[n]
+ branch = ctx.branch()
+ if branch in ('trunk', 'legacy-trunk',
+ '2.0', '2.1', '2.2', '2.3', '2.4', '3.0'):
+ ui.warn(' - changeset %s on disallowed branch %r!\n'
+ % (ctx, branch))
+ failed = True
+ if failed:
+ ui.warn('* Please strip the offending changeset(s)\n'
+ '* and re-do them, if needed, on another branch!\n')
+ return True
+
--
Repository URL: http://hg.python.org/hooks
More information about the Python-checkins
mailing list