diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -924,6 +924,7 @@ def branch(ui, repo, label=None, **opts) ' 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 @@ class dirstate(object): 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: diff --git a/tests/bundles/test-invalid-branch-name.hg b/tests/bundles/test-invalid-branch-name.hg new file mode 100644 index 0000000000000000000000000000000000000000..9023822853403dda519ea06dbe38fe81f9984b38 GIT binary patch literal 847 zc$@)G1F-x^M=>x$T4*^jL0KkKS=w`L=Kug9fB*mg@U8s2|MhX^cey|3{_CdTI~`E4 zOYkz2d00LlS7kr~dyd9!VB{DCG-7BBnqe|&kO72f(*T$PVFrdk#K;2x0GOFD69F_0 zQIcwA6nbhhXa;}{Jww!Kpfmsg0009Z00003KmY(DXpI_Z3V4)Yh5;}W00`4e&;n_o zzyb^=1i~^dknUy4_dYe-tO+6rJ(?OsEN2uD2f$9wb z>TOR@G|fTi)buBy)YHir4?WmSn9zuVpK`6-fJ$T#hiD2w^8k=6!~$46bFGDK;1sMn zqYkFIw_->&X@CtAhLWERq{;0gWDJT9@SVxKYUz@0+T%We;>TcE2eu?}k|YlxB~ci` zh+~8KCI_nyi)En;6A~0m^Uzis3xi%XV4Iep&n%IJ#qqd`*v2uKXn-cvb911<9$Gvj zi(-_ag=jb!T&CR@trzo|J zEUJqaDDR??%lTxYkCFq)LAEY!4=JWzUir*aeo=KBM)1d$`kEx=KfXkJauv%`BkvHpl>=#b6{JE>gFG_&m<=SM;Dcl$ zLrh_Ayeou9;26VT`Np*9x;Ye4AY!Ka$tM&M7+}Z)0~ENM5O1Aom(amSO%FoZFA0{4 zXk^b=;My?hENRipgpb}LrQl0Ptw=D4rY^){g{bU(Ww?HHidG!D;Ww~ Z`o(fkJ44+AP)3{lUC9*TLPKfIx15{}b?yKF diff --git a/tests/test-branches.t b/tests/test-branches.t --- a/tests/test-branches.t +++ b/tests/test-branches.t @@ -68,6 +68,23 @@ invalid characters abort: '\n' cannot be used in a name [255] +verify update will accept invalid legacy branch names + + $ hg init test-invalid-branch-name + $ cd test-invalid-branch-name + $ hg pull -u "$TESTDIR"/bundles/test-invalid-branch-name.hg + pulling from *test-invalid-branch-name.hg (glob) + requesting all changes + adding changesets + adding manifests + adding file changes + added 3 changesets with 3 changes to 2 files + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + + $ hg update '"colon:test"' + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ cd .. + $ echo 'd' >d $ hg add d $ hg branch 'a branch name much longer than the default justification used by branches'