mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
allow update to switch to a different branch if the repo is clean
This commit is contained in:
parent
9813e25f31
commit
58322272ec
@ -384,9 +384,13 @@ def update(repo, node, branchmerge, force, partial, wlock):
|
||||
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"))
|
||||
|
@ -12,9 +12,13 @@ hg commit -m"comment #1" -d "1000000 0"
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -93,7 +93,7 @@ user: test
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user