Mercurial > hg-stable
changeset 4202:b2873c587b1a
branch: require --force to shadow existing branches
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Mon, 12 Mar 2007 14:44:14 -0700 |
parents | 7e95381a9f1e |
children | aee3d312c32e |
files | mercurial/commands.py |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Mon Mar 12 13:58:06 2007 -0700 +++ b/mercurial/commands.py Mon Mar 12 14:44:14 2007 -0700 @@ -247,14 +247,21 @@ ui.status(_('(use "backout --merge" ' 'if you want to auto-merge)\n')) -def branch(ui, repo, label=None): +def branch(ui, repo, label=None, **opts): """set or show the current branch name With <name>, set the current branch name. Otherwise, show the current branch name. + + Unless --force is specified, branch will not let you set a + branch name that shadows an existing branch. """ if label is not None: + if not opts.get('force') and label in repo.branchtags(): + if label not in [p.branch() for p in repo.workingctx().parents()]: + raise util.Abort(_('a branch of the same name already exists' + ' (use --force to override)')) repo.opener("branch", "w").write(util.fromlocal(label) + '\n') else: b = util.tolocal(repo.workingctx().branch()) @@ -2622,7 +2629,10 @@ ('u', 'user', '', _('record user as committer')), ] + walkopts + commitopts, _('hg backout [OPTION]... REV')), - "branch": (branch, [], _('hg branch [NAME]')), + "branch": (branch, + [('f', 'force', None, + _('create branch even if it shadows an existing branch'))], + _('hg branch [NAME]')), "branches": (branches, [], _('hg branches')), "bundle": (bundle,