Mercurial > public > mercurial-scm > hg
diff mercurial/merge.py @ 9717:68a1b9d0663e
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.
author | Stuart W Marks <smarks@smarks.org> |
---|---|
date | Thu, 05 Nov 2009 10:53:59 +0100 |
parents | ea8c207a0f78 |
children | 1ee085511b89 |
line wrap: on
line diff
--- a/mercurial/merge.py Thu Nov 05 10:53:36 2009 +0100 +++ b/mercurial/merge.py Thu Nov 05 10:53:59 2009 +0100 @@ -412,24 +412,23 @@ -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 @@ 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