Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 44190:92b7caf4cb9e stable
branch: make --force work even when specifying revs
The `hg branch` command accepts a `--force` parameter that allows to
"set branch name even if it shadows an existing branch". However, before this
patch, that didn?t work when specifying revs with `-r`.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Sun, 01 Mar 2020 19:39:23 +0100 |
parents | b339faf3f843 |
children | d543ef183eb8 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Feb 24 00:20:47 2020 -0500 +++ b/mercurial/cmdutil.py Sun Mar 01 19:39:23 2020 +0100 @@ -961,7 +961,7 @@ raise error.UnknownCommand(cmd, allcmds) -def changebranch(ui, repo, revs, label): +def changebranch(ui, repo, revs, label, opts): """ Change the branch name of given revs to label """ with repo.wlock(), repo.lock(), repo.transaction(b'branches'): @@ -979,7 +979,11 @@ root = repo[roots.first()] rpb = {parent.branch() for parent in root.parents()} - if label not in rpb and label in repo.branchmap(): + if ( + not opts.get(b'force') + and label not in rpb + and label in repo.branchmap() + ): raise error.Abort(_(b"a branch of the same name already exists")) if repo.revs(b'obsolete() and %ld', revs):