Merge with stable
authorMatt Mackall <mpm@selenic.com>
Thu, 11 Feb 2010 17:44:01 -0600
changeset 10420 41d0ed2c79df
parent 10419 992dc3d39357 (current diff)
parent 10417 58e040c51231 (diff)
child 10421 452b6195e94c
child 10422 600142e7a028
Merge with stable
mercurial/changelog.py
mercurial/dirstate.py
tests/test-branches.out
--- a/mercurial/changelog.py	Thu Feb 11 17:13:22 2010 -0600
+++ b/mercurial/changelog.py	Thu Feb 11 17:44:01 2010 -0600
@@ -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)
--- a/mercurial/dirstate.py	Thu Feb 11 17:13:22 2010 -0600
+++ b/mercurial/dirstate.py	Thu Feb 11 17:44:01 2010 -0600
@@ -208,6 +208,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')
 
--- a/tests/test-branches	Thu Feb 11 17:13:22 2010 -0600
+++ b/tests/test-branches	Thu Feb 11 17:44:01 2010 -0600
@@ -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'
--- a/tests/test-branches.out	Thu Feb 11 17:13:22 2010 -0600
+++ b/tests/test-branches.out	Thu Feb 11 17:44:01 2010 -0600
@@ -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