[PATCH 2 of 3] update: allow branch crossing when clean
Stuart W Marks
smarks at smarks.org
Thu Aug 20 00:57:45 CDT 2009
# HG changeset patch
# User Stuart W Marks <smarks at smarks.org>
# Date 1250742664 25200
# Node ID 3154c4769de6ddf8372548939d458c7c087be0da
# Parent e0811a5c19f8c4788b997d6ebb0f0dc66f8d0436
update: allow branch crossing when clean
Update will now allow crossing branches within the same named branch,
if there are no uncommitted changes, without requiring the -c or -C
option. Minor confirmation to abort message if uncommitted changes are
found.
Add check to prevent both --check and --clean options from being given.
Behavior was that --check was ignored, but specifying both is nonsensical
and should be disallowed.
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 e0811a5c19f8 -r 3154c4769de6 mercurial/commands.py
--- a/mercurial/commands.py Wed Aug 19 21:30:32 2009 -0700
+++ b/mercurial/commands.py Wed Aug 19 21:31:04 2009 -0700
@@ -3049,6 +3049,10 @@
if not rev:
rev = node
+ if check and clean:
+ raise util.Abort(_("cannot specify both --check and --clean "
+ "at the same time"))
+
if not clean and check:
# we could use dirty() but we can ignore merge and branch trivia
c = repo[None]
diff -r e0811a5c19f8 -r 3154c4769de6 mercurial/merge.py
--- a/mercurial/merge.py Wed Aug 19 21:30:32 2009 -0700
+++ b/mercurial/merge.py Wed Aug 19 21:31:04 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 e0811a5c19f8 -r 3154c4769de6 tests/test-merge5.out
--- a/tests/test-merge5.out Wed Aug 19 21:30:32 2009 -0700
+++ b/tests/test-merge5.out Wed Aug 19 21:31:04 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 e0811a5c19f8 -r 3154c4769de6 tests/test-up-local-change.out
--- a/tests/test-up-local-change.out Wed Aug 19 21:30:32 2009 -0700
+++ b/tests/test-up-local-change.out Wed Aug 19 21:31:04 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 e0811a5c19f8 -r 3154c4769de6 tests/test-update-branches
--- a/tests/test-update-branches Wed Aug 19 21:30:32 2009 -0700
+++ b/tests/test-update-branches Wed Aug 19 21:31:04 2009 -0700
@@ -34,21 +34,18 @@
#
# 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
# "same branch" = crossing to branch with same name
@@ -88,11 +85,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 e0811a5c19f8 -r 3154c4769de6 tests/test-update-branches.out
--- a/tests/test-update-branches.out Wed Aug 19 21:30:32 2009 -0700
+++ b/tests/test-update-branches.out Wed Aug 19 21:31:04 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