Mercurial > hg
changeset 3580:41989e55fa37
allow update to switch to a different branch if the repo is clean
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 29 Oct 2006 13:08:10 +0100 |
parents | 0ed2732aa393 |
children | be61bd32046c fffc8a733bf9 |
files | mercurial/merge.py tests/test-merge5 tests/test-merge5.out tests/test-up-local-change.out |
diffstat | 4 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Sun Oct 29 10:55:38 2006 +0100 +++ b/mercurial/merge.py Sun Oct 29 13:08:10 2006 +0100 @@ -384,9 +384,13 @@ if branchmerge: raise util.Abort(_("there is nothing to merge, just use " "'hg update' or look at 'hg heads'")) - elif not (overwrite or branchmerge): - raise util.Abort(_("update spans branches, use 'hg merge' " - "or 'hg update -C' to lose changes")) + elif not branchmerge: + if not overwrite: + if wc.files(): + raise util.Abort(_("outstanding uncommited changes, use " + "'hg update -C' to lose changes")) + else: + overwrite = True if branchmerge and not forcemerge: if wc.modified() or wc.added() or wc.removed(): raise util.Abort(_("outstanding uncommitted changes"))
--- a/tests/test-merge5 Sun Oct 29 10:55:38 2006 +0100 +++ b/tests/test-merge5 Sun Oct 29 13:08:10 2006 +0100 @@ -12,9 +12,13 @@ hg update 0 rm b hg commit -A -m"comment #2" -d "1000000 0" + +echo This is file a > a # in theory, we shouldn't need the "-y" below, but it prevents # this test from hanging when "hg update" erroneously prompts the # user for "keep or delete" +hg update -y 1 # should fail (unclean repo) +hg revert a hg update -y 1 exit 0
--- a/tests/test-merge5.out Sun Oct 29 10:55:38 2006 +0100 +++ b/tests/test-merge5.out Sun Oct 29 13:08:10 2006 +0100 @@ -1,3 +1,4 @@ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved removing b -abort: update spans branches, use 'hg merge' or 'hg update -C' to lose changes +abort: outstanding uncommited changes, use 'hg update -C' to lose changes +1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-up-local-change.out Sun Oct 29 10:55:38 2006 +0100 +++ b/tests/test-up-local-change.out Sun Oct 29 13:08:10 2006 +0100 @@ -93,7 +93,7 @@ date: Mon Jan 12 13:46:40 1970 +0000 summary: 2 -abort: update spans branches, use 'hg merge' or 'hg update -C' to lose changes +abort: outstanding uncommited changes, use 'hg update -C' to lose changes failed abort: outstanding uncommitted changes failed