# HG changeset patch # User Stuart W Marks # Date 2009-11-05 09:53:59 # Node ID 68a1b9d0663e209bd7212fb7d0dd2842b693060c # Parent ea8c207a0f78f1f79725c75fcd27bc9a57f6b24d update: allow branch crossing without -c or -C, with no uncommitted changes Update will now allow crossing branches within the same named branch, when given a specific revision, if the working dir is clean, without requiring the -c or -C option. Abort if no revision is given and this would cross branches. Minor change 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-up-local-change.out with new message. diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -412,24 +412,23 @@ def update(repo, node, branchmerge, forc -c -C dirty rev | linear same cross n n n n | ok (1) x - n n n y | ok (1) ok - n n y * | merge (2) (3) + n n n y | ok ok ok + n n y * | merge (2) (2) n y * * | --- discard --- - y n y * | --- (4) --- + y n y * | --- (3) --- y n n * | --- ok --- - y y * * | --- (5) --- + y y * * | --- (4) --- x = can't happen * = don't-care - 1 = abort: crosses branches (use 'hg merge' or 'hg update -C') - 2 = abort: crosses branches (use 'hg merge' or 'hg update -C' - to discard changes) - 3 = abort: crosses named branches (use 'hg update -C' to - discard changes) - 4 = abort: uncommitted local changes - 5 = incompatible options (checked in commands.py) + 1 = abort: crosses branches (use 'hg merge' or 'hg update -c') + 2 = abort: crosses branches (use 'hg merge' to merge or + use 'hg update -C' to discard changes) + 3 = abort: uncommitted local changes + 4 = incompatible options (checked in commands.py) """ + onode = node wlock = repo.wlock() try: wc = repo[None] @@ -467,17 +466,14 @@ def update(repo, node, branchmerge, forc 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 " - "'hg update -C' to discard changes)")) + raise util.Abort(_("crosses branches (use 'hg merge' to merge " + "or use 'hg update -C' to discard changes)")) + elif onode is None: + raise util.Abort(_("crosses branches (use 'hg merge' or use " + "'hg update -c')")) else: - # Allow jumping branches if there are no changes + # Allow jumping branches if clean and specific rev given overwrite = True ### calculate phase diff --git a/tests/test-merge5.out b/tests/test-merge5.out --- a/tests/test-merge5.out +++ b/tests/test-merge5.out @@ -2,6 +2,6 @@ 1 files updated, 0 files merged, 0 files 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' to 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 --git a/tests/test-up-local-change.out b/tests/test-up-local-change.out --- a/tests/test-up-local-change.out +++ b/tests/test-up-local-change.out @@ -111,7 +111,7 @@ user: test 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' to merge or use 'hg update -C' to discard changes) failed abort: outstanding uncommitted changes (use 'hg status' to list changes) failed diff --git a/tests/test-update-branches.out b/tests/test-update-branches.out --- a/tests/test-update-branches.out +++ b/tests/test-update-branches.out @@ -16,14 +16,14 @@ o 0:b608b9236435 1 files updated, 0 files merged, 0 files removed, 0 files unresolved parent=5 % norevtest none clean same 2 -abort: crosses branches (use 'hg merge' or 'hg update -C') +abort: crosses branches (use 'hg merge' or use 'hg update -c') parent=2 % revtest none clean linear 1 2 1 files updated, 0 files merged, 0 files removed, 0 files unresolved parent=2 % revtest none clean same 2 3 -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 cross 3 4 1 files updated, 0 files merged, 0 files removed, 0 files unresolved parent=4 @@ -32,11 +32,11 @@ 1 files updated, 0 files merged, 0 files parent=2 M foo % revtest none dirty same 2 3 -abort: crosses branches (use 'hg merge' or 'hg update -C' to discard changes) +abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' to discard changes) parent=2 M foo % revtest none dirty cross 3 4 -abort: crosses named branches (use 'hg update -C' to discard changes) +abort: crosses branches (use 'hg merge' to merge or use 'hg update -C' to discard changes) parent=3 M foo % revtest -C dirty linear 1 2