@@ -1058,7 +1058,8 @@ def bookmark(ui, repo, *names, **opts):
@command('branch',
[('f', 'force', None,
_('set branch name even if it shadows an existing branch')),
- ('C', 'clean', None, _('reset branch name to parent branch name'))],
+ ('C', 'clean', None, _('reset branch name to parent branch name')),
+ ('n', 'new', '', _('mark working directory as creating new branch'))],
_('[-fC] [NAME]'))
def branch(ui, repo, label=None, **opts):
"""set or show the current branch name
@@ -1069,11 +1070,12 @@ def branch(ui, repo, label=None, **opts)
light-weight bookmark instead. See :hg:`help glossary` for more
information about named branches and bookmarks.
- With no argument, show the current branch name. With one argument,
- set the working directory branch name (the branch will not exist
- in the repository until the next commit). Standard practice
- recommends that primary development take place on the 'default'
- branch.
+ With no argument, show the current branch name.
+
+ With no argument or --new, set the working directory branch name to create
+ a new branch (the branch will not exist in the repository until the next
+ commit). Standard practice recommends that primary development take place
+ on the 'default' branch.
Unless -f/--force is specified, branch will not let you set a
branch name that already exists.
@@ -1087,6 +1089,12 @@ def branch(ui, repo, label=None, **opts)
Returns 0 on success.
"""
+ new = opts.get('new')
+ if new:
+ if label:
+ raise util.Abort(_("--new only takes one branch name"))
+ label = new
+
if label:
label = label.strip()
@@ -11,7 +11,11 @@
(branches are permanent and global, did you want a bookmark?)
$ hg commit -d '1 0' -m "Adding a branch"
- $ hg branch q
+ $ hg branch --new q q
+ abort: --new only takes one branch name
+ [255]
+
+ $ hg branch --new q
marked working directory as branch q
(branches are permanent and global, did you want a bookmark?)
$ echo 'aa' >a
@@ -221,7 +221,7 @@ Show all commands + options
backout: merge, commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user
bisect: reset, good, bad, skip, extend, command, noupdate
bookmarks: force, rev, delete, rename, inactive, template
- branch: force, clean
+ branch: force, clean, new
branches: active, closed, template
bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure
cat: output, rev, decode, include, exclude