[PATCH STABLE V2] update: allow update to existing branches with invalid names (issue3710)

Matt Mackall mpm at selenic.com
Wed Nov 28 15:32:47 CST 2012


On Wed, 2012-11-28 at 08:21 -0500, Tim Henigan wrote:
> 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:

Hiding in here is an opportunity to fix another latent defect: the first
arg of checknewlabel is supposed to be a repo object:

http://www.selenic.com/hg/file/d0d99c8bdf51/mercurial/scmutil.py#l30

This arg is there to let checknewlabel centralize all the duplicate name
checks (which is obviously yet to be implemented). No repo object was
available in dirstate.setbranch, but now it obviously is.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list