Mercurial > hg-stable
changeset 7006:92d44ec32430
branch: added more support for named branches
hg branch now has a -C (--clean) option, to reset the current (dirstate)
branch to the branch of the last commit (first parent).
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Mon, 08 Sep 2008 12:55:27 +0200 |
parents | 7739b61897df |
children | a6b74fbb5ce0 |
files | mercurial/commands.py tests/test-branches tests/test-branches.out |
diffstat | 3 files changed, 40 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Mon Sep 08 11:32:53 2008 +0200 +++ b/mercurial/commands.py Mon Sep 08 12:55:27 2008 +0200 @@ -373,10 +373,17 @@ Unless --force is specified, branch will not let you set a branch name that shadows an existing branch. + Use --clean to reset the working directory branch to that of the + parent of the working directory, negating a previous branch change. + Use the command 'hg update' to switch to an existing branch. """ - if label: + if opts.get('clean'): + label = repo[None].parents()[0].branch() + repo.dirstate.setbranch(label) + ui.status(_('reset working directory to branch %s\n') % label) + elif label: if not opts.get('force') and label in repo.branchtags(): if label not in [p.branch() for p in repo.parents()]: raise util.Abort(_('a branch of the same name already exists' @@ -2987,8 +2994,9 @@ "branch": (branch, [('f', 'force', None, - _('set branch name even if it shadows an existing branch'))], - _('hg branch [-f] [NAME]')), + _('set branch name even if it shadows an existing branch')), + ('C', 'clean', None, _('reset branch name to parent branch name'))], + _('hg branch [-fC] [NAME]')), "branches": (branches, [('a', 'active', False,
--- a/tests/test-branches Mon Sep 08 11:32:53 2008 +0200 +++ b/tests/test-branches Mon Sep 08 12:55:27 2008 +0200 @@ -11,6 +11,11 @@ hg branch a hg commit -d '1 0' -u test -m "Adding a branch" +hg branch q +echo 'aa' >a +hg branch -C +hg commit -d '2 0' -u test -m "Adding to a branch" + hg update -C 0 echo 'b' >b hg add b
--- a/tests/test-branches.out Mon Sep 08 11:32:53 2008 +0200 +++ b/tests/test-branches.out Mon Sep 08 12:55:27 2008 +0200 @@ -1,21 +1,34 @@ marked working directory as branch a +marked working directory as branch q +reset working directory to branch a 0 files updated, 0 files merged, 1 files removed, 0 files unresolved marked working directory as branch b created new head -0 files updated, 0 files merged, 1 files removed, 0 files unresolved -created new head +1 files updated, 0 files merged, 2 files removed, 0 files unresolved marked working directory as branch c marked working directory as branch a branch name much longer than the default justification used by branches -a branch name much longer than the default justification used by branches 6:b8cb5af34c4d -b 4:22df7444f7c1 -a 1:dd6b440dd85a -c 5:5ca481e59b8c (inactive) +a branch name much longer than the default justification used by branches 7:10ff5895aa57 +b 4:aee39cd168d0 +c 6:589736a22561 (inactive) +a 5:d8cbc61dbaa6 (inactive) default 0:19709c5a4e75 (inactive) ------- -a branch name much longer than the default justification used by branches 6:b8cb5af34c4d -b 4:22df7444f7c1 -a 1:dd6b440dd85a +a branch name much longer than the default justification used by branches 7:10ff5895aa57 +b 4:aee39cd168d0 --- Branch a +changeset: 5:d8cbc61dbaa6 +branch: a +parent: 2:881fe2b92ad0 +user: test +date: Thu Jan 01 00:00:04 1970 +0000 +summary: Adding b branch head 2 + +changeset: 2:881fe2b92ad0 +branch: a +user: test +date: Thu Jan 01 00:00:02 1970 +0000 +summary: Adding to a branch + changeset: 1:dd6b440dd85a branch: a user: test @@ -23,20 +36,13 @@ summary: Adding a branch ---- Branch b -changeset: 4:22df7444f7c1 -branch: b -parent: 2:ac22033332d1 -user: test -date: Thu Jan 01 00:00:04 1970 +0000 -summary: Adding b branch head 2 - -changeset: 3:aee39cd168d0 +changeset: 4:aee39cd168d0 branch: b user: test date: Thu Jan 01 00:00:03 1970 +0000 summary: Adding b branch head 1 -changeset: 2:ac22033332d1 +changeset: 3:ac22033332d1 branch: b parent: 0:19709c5a4e75 user: test