--- a/mercurial/commands.py Sat Mar 22 19:01:09 2008 +0100
+++ b/mercurial/commands.py Sat Mar 22 13:30:08 2008 -0500
@@ -2750,15 +2750,15 @@
tip of the current branch if none is specified.
See 'hg help dates' for a list of formats valid for -d/--date.
- If there are no outstanding changes in the working directory and
- there is a linear relationship between the current version and the
- requested version, the result is the requested version.
-
- To merge the working directory with another revision, use the
- merge command.
-
- By default, update will refuse to run if doing so would require
- discarding local changes.
+ If there are no outstanding changes in the working directory, the
+ result is the requested version.
+
+ If the requested version is a descendant of the working directory
+ and there are outstanding changes, those changes will be merged
+ into the result.
+
+ By default, update will refuse to run if there are outstanding
+ changes and the update spans branches.
"""
if rev and node:
raise util.Abort(_("please specify just one revision"))
--- a/mercurial/merge.py Sat Mar 22 19:01:09 2008 +0100
+++ b/mercurial/merge.py Sat Mar 22 13:30:08 2008 -0500
@@ -364,8 +364,11 @@
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"))
+ if wc.files() or wc.deleted():
+ raise util.Abort(_("update spans branches, use 'hg merge' "
+ "or 'hg update -C' to lose changes"))
+ # Allow jumping branches if there are no changes
+ overwrite = True
if branchmerge and not forcemerge:
if wc.files() or wc.deleted():
raise util.Abort(_("outstanding uncommitted changes"))
--- a/tests/test-merge5 Sat Mar 22 19:01:09 2008 +0100
+++ b/tests/test-merge5 Sat Mar 22 13:30:08 2008 -0500
@@ -12,9 +12,14 @@
hg update 0
rm b
hg commit -A -m"comment #2" -d "1000000 0"
+mv a c
# 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"
+echo % should abort
+hg update -y 1
+mv c a
+echo % should succeed
hg update -y 1
exit 0
--- a/tests/test-merge5.out Sat Mar 22 19:01:09 2008 +0100
+++ b/tests/test-merge5.out Sat Mar 22 13:30:08 2008 -0500
@@ -1,4 +1,7 @@
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
removing b
created new head
+% should abort
abort: update spans branches, use 'hg merge' or 'hg update -C' to lose changes
+% should succeed
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved