comparison 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
comparison
equal deleted inserted replaced
9716:ea8c207a0f78 9717:68a1b9d0663e
410 410
411 This logic is tested by test-update-branches. 411 This logic is tested by test-update-branches.
412 412
413 -c -C dirty rev | linear same cross 413 -c -C dirty rev | linear same cross
414 n n n n | ok (1) x 414 n n n n | ok (1) x
415 n n n y | ok (1) ok 415 n n n y | ok ok ok
416 n n y * | merge (2) (3) 416 n n y * | merge (2) (2)
417 n y * * | --- discard --- 417 n y * * | --- discard ---
418 y n y * | --- (4) --- 418 y n y * | --- (3) ---
419 y n n * | --- ok --- 419 y n n * | --- ok ---
420 y y * * | --- (5) --- 420 y y * * | --- (4) ---
421 421
422 x = can't happen 422 x = can't happen
423 * = don't-care 423 * = don't-care
424 1 = abort: crosses branches (use 'hg merge' or 'hg update -C') 424 1 = abort: crosses branches (use 'hg merge' or 'hg update -c')
425 2 = abort: crosses branches (use 'hg merge' or 'hg update -C' 425 2 = abort: crosses branches (use 'hg merge' to merge or
426 to discard changes) 426 use 'hg update -C' to discard changes)
427 3 = abort: crosses named branches (use 'hg update -C' to 427 3 = abort: uncommitted local changes
428 discard changes) 428 4 = incompatible options (checked in commands.py)
429 4 = abort: uncommitted local changes
430 5 = incompatible options (checked in commands.py)
431 """ 429 """
432 430
431 onode = node
433 wlock = repo.wlock() 432 wlock = repo.wlock()
434 try: 433 try:
435 wc = repo[None] 434 wc = repo[None]
436 if node is None: 435 if node is None:
437 # tip of current branch 436 # tip of current branch
465 raise util.Abort(_("outstanding uncommitted changes " 464 raise util.Abort(_("outstanding uncommitted changes "
466 "(use 'hg status' to list changes)")) 465 "(use 'hg status' to list changes)"))
467 elif not overwrite: 466 elif not overwrite:
468 if pa == p1 or pa == p2: # linear 467 if pa == p1 or pa == p2: # linear
469 pass # all good 468 pass # all good
470 elif p1.branch() == p2.branch():
471 if wc.files() or wc.deleted():
472 raise util.Abort(_("crosses branches (use 'hg merge' or "
473 "'hg update -C' to discard changes)"))
474 raise util.Abort(_("crosses branches (use 'hg merge' "
475 "or 'hg update -C')"))
476 elif wc.files() or wc.deleted(): 469 elif wc.files() or wc.deleted():
477 raise util.Abort(_("crosses named branches (use " 470 raise util.Abort(_("crosses branches (use 'hg merge' to merge "
478 "'hg update -C' to discard changes)")) 471 "or use 'hg update -C' to discard changes)"))
472 elif onode is None:
473 raise util.Abort(_("crosses branches (use 'hg merge' or use "
474 "'hg update -c')"))
479 else: 475 else:
480 # Allow jumping branches if there are no changes 476 # Allow jumping branches if clean and specific rev given
481 overwrite = True 477 overwrite = True
482 478
483 ### calculate phase 479 ### calculate phase
484 action = [] 480 action = []
485 if not force: 481 if not force: