[PATCH STABLE] branch: avoid using reserved tag names
Wagner Bruna
wagner.bruna+mercurial at gmail.com
Thu Feb 11 08:17:09 CST 2010
# HG changeset patch
# User Wagner Bruna <wbruna at softwareexpress.com.br>
# Date 1265896968 7200
# Branch stable
# Node ID 58e040c5123127898708e9305f1e92942e858fc3
# Parent b8801b58bbd8fe42571e52c0ba8646bb59077efb
branch: avoid using reserved tag names
Reported as Debian bug #552423.
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -218,8 +218,13 @@
parseddate = "%d %d" % util.parsedate(date)
else:
parseddate = "%d %d" % util.makedate()
- if extra and extra.get("branch") in ("default", ""):
- del extra["branch"]
+ if extra:
+ branch = extra.get("branch")
+ if branch in ("default", ""):
+ del extra["branch"]
+ elif branch in (".", "null", "tip"):
+ raise error.RevlogError(_('the name \'%s\' is reserved')
+ % branch)
if extra:
extra = encodeextra(extra)
parseddate = "%s %s" % (parseddate, extra)
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -202,6 +202,8 @@
self._pl = p1, p2
def setbranch(self, branch):
+ if branch in ['tip', '.', 'null']:
+ raise util.Abort(_('the name \'%s\' is reserved') % branch)
self._branch = branch
self._opener("branch", "w").write(branch + '\n')
diff --git a/tests/test-branches b/tests/test-branches
--- a/tests/test-branches
+++ b/tests/test-branches
@@ -36,6 +36,10 @@
hg branch c
hg commit -d '5 0' -m "Adding c branch"
+hg branch tip
+hg branch null
+hg branch .
+
echo 'd' >d
hg add d
hg branch 'a branch name much longer than the default justification used by branches'
diff --git a/tests/test-branches.out b/tests/test-branches.out
--- a/tests/test-branches.out
+++ b/tests/test-branches.out
@@ -6,6 +6,9 @@
created new head
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
marked working directory as branch c
+abort: the name 'tip' is reserved
+abort: the name 'null' is reserved
+abort: the name '.' is reserved
marked working directory as branch a branch name much longer than the default justification used by branches
a branch name much longer than the default justification used by branches 7:10ff5895aa57
b 4:aee39cd168d0
More information about the Mercurial-devel
mailing list