[Python-checkins] hooks: Tentative branch check hook

antoine.pitrou python-checkins at python.org
Sat Feb 26 21:00:34 CET 2011


antoine.pitrou pushed 2f27be828fa0 to hooks:

http://hg.python.org/hooks/rev/2f27be828fa0
changeset:   29:2f27be828fa0
tag:         tip
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Sat Feb 26 21:00:31 2011 +0100
summary:
  Tentative branch check hook

files:
  checkbranch.py

diff --git a/checkbranch.py b/checkbranch.py
new file mode 100644
--- /dev/null
+++ b/checkbranch.py
@@ -0,0 +1,23 @@
+"""
+Mercurial hook to check that individual changesets don't happen on a
+forbidden branch.
+
+To use the changeset hook in a local repository, include something like the
+following in your hgrc file.
+
+[hooks]
+pretxncommit.checkbranch = python:/home/hg/repos/hooks/checkbranch.py:hook
+"""
+
+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))

--
Repository URL: http://hg.python.org/hooks


More information about the Python-checkins mailing list