[PATCH STABLE] only check for valid label on branch creation

Tim Henigan tim.henigan at gmail.com
Tue Nov 27 09:26:02 CST 2012


# HG changeset patch
# User Tim Henigan <tim.henigan at gmail.com>
# Date 1354024055 18000
# Branch stable
# Node ID 571502912c98ed33ad70b153ad5a3b2f65eecdfa
# Parent  54cedee86e5126188b0dcfbd7015bcdca7f6c2e2
only check for valid label on branch creation

Starting with 361ab1e2086f, users are no longer able to update a
working copy to a branch named with a "bad" character (such as ':').

Prior to v2.4, it was possible to create branch names using "bad"
characters, so this breaks backwards compatibility.

Mercurial must allow users to update to existing branches with bad
names.  However, it should continue to prevent the creation of new
branches with bad names.

The original problem was reported in (issue3710).

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -924,6 +924,7 @@
                                        ' exists'),
                                      # i18n: "it" refers to an existing branch
                                      hint=_("use 'hg update' to switch to it"))
+            scmutil.checknewlabel(None, label, 'branch')
             repo.dirstate.setbranch(label)
             ui.status(_('marked working directory as branch %s\n') % label)
             ui.status(_('(branches are permanent and global, '
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -261,7 +261,6 @@
 
     def setbranch(self, branch):
         # no repo object here, just check for reserved names
-        scmutil.checknewlabel(None, branch, 'branch')
         self._branch = encoding.fromlocal(branch)
         f = self._opener('branch', 'w', atomictemp=True)
         try:


More information about the Mercurial-devel mailing list