comparison mercurial/merge.py @ 4410:bbc97d419b16

Add fast-forward branch merging
author Brendan Cully <brendan@kublai.com>
date Sun, 06 May 2007 20:27:45 -0700
parents 47371e1c1db4
children 0912d8df5e19
comparison
equal deleted inserted replaced
4409:28b7d949ef6a 4410:bbc97d419b16
487 forcemerge = force and branchmerge 487 forcemerge = force and branchmerge
488 pl = wc.parents() 488 pl = wc.parents()
489 p1, p2 = pl[0], repo.changectx(node) 489 p1, p2 = pl[0], repo.changectx(node)
490 pa = p1.ancestor(p2) 490 pa = p1.ancestor(p2)
491 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2) 491 fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
492 fastforward = False
492 493
493 ### check phase 494 ### check phase
494 if not overwrite and len(pl) > 1: 495 if not overwrite and len(pl) > 1:
495 raise util.Abort(_("outstanding uncommitted merges")) 496 raise util.Abort(_("outstanding uncommitted merges"))
496 if pa == p1 or pa == p2: # is there a linear path from p1 to p2? 497 if pa == p1 or pa == p2: # is there a linear path from p1 to p2?
497 if branchmerge: 498 if branchmerge:
498 raise util.Abort(_("there is nothing to merge, just use " 499 if p1.branch() != p2.branch():
499 "'hg update' or look at 'hg heads'")) 500 fastforward = True
501 branchmerge = False
502 else:
503 raise util.Abort(_("there is nothing to merge, just use "
504 "'hg update' or look at 'hg heads'"))
500 elif not (overwrite or branchmerge): 505 elif not (overwrite or branchmerge):
501 raise util.Abort(_("update spans branches, use 'hg merge' " 506 raise util.Abort(_("update spans branches, use 'hg merge' "
502 "or 'hg update -C' to lose changes")) 507 "or 'hg update -C' to lose changes"))
503 if branchmerge and not forcemerge: 508 if branchmerge and not forcemerge:
504 if wc.files(): 509 if wc.files():
523 stats = applyupdates(repo, action, wc, p2) 528 stats = applyupdates(repo, action, wc, p2)
524 529
525 if not partial: 530 if not partial:
526 recordupdates(repo, action, branchmerge) 531 recordupdates(repo, action, branchmerge)
527 repo.dirstate.setparents(fp1, fp2) 532 repo.dirstate.setparents(fp1, fp2)
528 if not branchmerge: 533 if not branchmerge and not fastforward:
529 repo.dirstate.setbranch(p2.branch()) 534 repo.dirstate.setbranch(p2.branch())
530 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3]) 535 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
531 536
532 return stats 537 return stats
533 538