[PATCH 2 of 3] update: allow branch crossing without -c or -C, with no uncommitted changes

Stuart W Marks smarks at smarks.org
Fri Sep 18 01:45:19 CDT 2009


# HG changeset patch
# User Stuart W Marks <smarks at smarks.org>
# Date 1253254168 25200
# Node ID f820ee4056c2833af4458f729a2c2f14ba96ad6c
# Parent  c0fd3e7cc502916a0293b18eaa279c00ad07faf1
update: allow branch crossing without -c or -C, with no uncommitted changes

Update will now allow crossing branches within the same named branch,
if the repository is clean (that is, if there are no uncommitted changes),
without requiring the -c or -C option. Minor confirmation to abort message
if uncommitted changes are found.

Modify test-update-branches and output to reflect the altered case. Modify
test-merge5.out to reflect the altered case. Modify
test-update-local-change.out with new message.

diff -r c0fd3e7cc502 -r f820ee4056c2 mercurial/merge.py
--- a/mercurial/merge.py	Thu Sep 17 23:09:25 2009 -0700
+++ b/mercurial/merge.py	Thu Sep 17 23:09:28 2009 -0700
@@ -439,14 +439,8 @@
         elif not overwrite:
             if pa == p1 or pa == p2: # linear
                 pass # all good
-            elif p1.branch() == p2.branch():
-                if wc.files() or wc.deleted():
-                    raise util.Abort(_("crosses branches (use 'hg merge' or "
-                                       "'hg update -C' to discard changes)"))
-                raise util.Abort(_("crosses branches (use 'hg merge' "
-                                   "or 'hg update -C')"))
             elif wc.files() or wc.deleted():
-                raise util.Abort(_("crosses named branches (use "
+                raise util.Abort(_("crosses branches (use 'hg merge' or use "
                                    "'hg update -C' to discard changes)"))
             else:
                 # Allow jumping branches if there are no changes
diff -r c0fd3e7cc502 -r f820ee4056c2 tests/test-merge5.out
--- a/tests/test-merge5.out	Thu Sep 17 23:09:25 2009 -0700
+++ b/tests/test-merge5.out	Thu Sep 17 23:09:28 2009 -0700
@@ -2,6 +2,6 @@
 removing b
 created new head
 % should abort
-abort: crosses branches (use 'hg merge' or 'hg update -C' to discard changes)
+abort: crosses branches (use 'hg merge' or use 'hg update -C' to discard changes)
 % should succeed
-abort: crosses branches (use 'hg merge' or 'hg update -C')
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
diff -r c0fd3e7cc502 -r f820ee4056c2 tests/test-up-local-change.out
--- a/tests/test-up-local-change.out	Thu Sep 17 23:09:25 2009 -0700
+++ b/tests/test-up-local-change.out	Thu Sep 17 23:09:28 2009 -0700
@@ -111,7 +111,7 @@
 date:        Mon Jan 12 13:46:40 1970 +0000
 summary:     2
 
-abort: crosses branches (use 'hg merge' or 'hg update -C' to discard changes)
+abort: crosses branches (use 'hg merge' or use 'hg update -C' to discard changes)
 failed
 abort: outstanding uncommitted changes (use 'hg status' to list changes)
 failed
diff -r c0fd3e7cc502 -r f820ee4056c2 tests/test-update-branches
--- a/tests/test-update-branches	Thu Sep 17 23:09:25 2009 -0700
+++ b/tests/test-update-branches	Thu Sep 17 23:09:28 2009 -0700
@@ -34,25 +34,27 @@
 #
 # opts           state        linear      same branch     diff branch
 # 
-# none           clean          OK         abort(1)          OK
-# none           dirty        merge        abort(2)        abort(3)
+# none           clean          OK           OK              OK
+# none           dirty        merge        abort(1)        abort(1)
 #
 # -c             clean          OK           OK              OK
-# -c             dirty        abort(4)     abort(4)        abort(4)
+# -c             dirty        abort(2)     abort(2)        abort(2)
 #
 # -C             clean          OK           OK              OK
 # -C             dirty        discard      discard         discard
 #
-# abort(1) = abort: crosses branches (use 'hg merge' or 'hg update -C')
-# abort(2) = abort: crosses branches (use 'hg merge' or 'hg update -C'
+# abort(1) = abort: crosses branches (use 'hg merge' or use 'hg update -C'
 #            to discard changes)
-# abort(3) = abort: crosses named branches (use 'hg update -C' to
-#            discard changes)
-# abort(4) = abort: uncommitted local changes
+# abort(2) = abort: uncommitted local changes
 #
-# "linear" = update to an ancestor or descendant
+# "linear" = update to an ancestor or descendant; we actually only test
+#            updating to a descendant
 # "same branch" = crossing to branch with same name
 # "diff branch" = crossing to a branch with a different name
+#
+# Note that the expected behaviors for "same branch" and "diff branch" 
+# are identical. They were different in the past. The test cases are
+# preserved here for historical interest.
 
 function revtest { # msg {clean|dirty} start-rev target-rev [update-opts]
     echo % revtest $1
@@ -88,11 +90,11 @@
 #
 # opts           state        linear     cross branch
 # 
-# none           clean          OK         abort(1)
-# none           dirty        merge        abort(2)
+# none           clean          OK           OK
+# none           dirty        merge        abort(1)
 #
 # -c             clean          OK           OK
-# -c             dirty        abort(4)     abort(4)
+# -c             dirty        abort(2)     abort(2)
 #
 # -C             clean          OK           OK
 # -C             dirty        discard      discard
diff -r c0fd3e7cc502 -r f820ee4056c2 tests/test-update-branches.out
--- a/tests/test-update-branches.out	Thu Sep 17 23:09:25 2009 -0700
+++ b/tests/test-update-branches.out	Thu Sep 17 23:09:28 2009 -0700
@@ -16,8 +16,8 @@
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 parent=2
 % revtest none clean same
-abort: crosses branches (use 'hg merge' or 'hg update -C')
-parent=2
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+parent=3
 % revtest none clean diff
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 parent=4
@@ -26,11 +26,11 @@
 parent=2
 M foo
 % revtest none dirty same
-abort: crosses branches (use 'hg merge' or 'hg update -C' to discard changes)
+abort: crosses branches (use 'hg merge' or use 'hg update -C' to discard changes)
 parent=2
 M foo
 % revtest none dirty diff
-abort: crosses named branches (use 'hg update -C' to discard changes)
+abort: crosses branches (use 'hg merge' or use 'hg update -C' to discard changes)
 parent=3
 M foo
 % revtest -c clean linear
@@ -76,14 +76,14 @@
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 parent=5
 % norevtest none clean cross
-abort: crosses branches (use 'hg merge' or 'hg update -C')
-parent=2
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+parent=3
 % norevtest none dirty linear
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 parent=5
 M foo
 % norevtest none dirty cross
-abort: crosses branches (use 'hg merge' or 'hg update -C' to discard changes)
+abort: crosses branches (use 'hg merge' or use 'hg update -C' to discard changes)
 parent=2
 M foo
 % norevtest -c clean linear


More information about the Mercurial-devel mailing list