Check for bad branch names.
--- a/hg.rst Mon Jul 11 11:11:18 2011 +0300
+++ b/hg.rst Mon Jul 18 16:37:38 2011 +0300
@@ -93,6 +93,10 @@
$ hg convert --filemap filemap.txt $repo_orig $repo_new
$ hg -R $repo_new up
+** Fix branch names.
+
+
+
* Join history of two repos.
$ cat >filemap1.txt <<EOF
@@ -337,3 +341,32 @@
http://mercurial.selenic.com/wiki/TipsAndTricks#Merge_or_rebase_with_uncommitted_changes
http://mercurial.selenic.com/wiki/ShelveExtension
+* Hooks.
+
+** Check for bad branch names.
+
+.hg/hgcheck.py::
+
+ import re
+ goodbranch_re = r'((bug|feature)#\d|release-1\.\d\.\d|default)$'
+ def precommit_badbranchname(ui, repo, hooktype, **kwargs):
+ ui.warn('"%s" hook failed\n' % hooktype)
+ for rev in repo:
+ branch = repo[rev].branch()
+ re_ = re.compile(goodbranch_re)
+ if not re_.match(branch):
+ ui.warn('Invalid branch name "%s".\nUse one of default, bug#ID, feature#ID or release-1.XX.XX.\n' % branch)
+ return True
+ return False
+
+.hg/hgrc::
+
+ [hooks]
+ precommit.badbranchname = python:.hg/hgcheck.py:precommit_badbranchname
+ # precommit.gg = python:my.hgcheck.py.precommit_badbranch
+ prechangegroup.badbranchname = python:.hg/hgcheck.py:precommit_badbranchname
+
+Read more:
+
+ http://mercurial.selenic.com/wiki/HookExamples
+