# HG changeset patch # User Matt Mackall # Date 2006-09-29 21:39:38 # Node ID e67c22bc8bba14d5bf57abed4b48be81502a36fe # Parent ebdb3f616bc00913509538508b3810df70a90b04 merge: use repo.parents and parent contexts in update diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -320,12 +320,12 @@ def update(repo, node, branchmerge=False ### check phase - pl = repo.dirstate.parents() - if not overwrite and pl[1] != nullid: + pl = repo.parents() + if not overwrite and len(pl) > 1: raise util.Abort(_("outstanding uncommitted merges")) - p1, p2 = pl[0], node - pa = repo.changelog.ancestor(p1, p2) + p1, p2 = pl[0], repo.changectx(node) + pa = p1.ancestor(p2) # are we going backwards? backwards = (pa == p2) @@ -345,17 +345,16 @@ def update(repo, node, branchmerge=False if modified or added or removed: raise util.Abort(_("outstanding uncommitted changes")) - m1 = repo.changectx(p1).manifest().copy() - m2 = repo.changectx(p2).manifest().copy() - ma = repo.changectx(pa).manifest() + m1 = p1.manifest().copy() + m2 = p2.manifest().copy() + ma = pa.manifest() # resolve the manifest to determine which files # we care about merging repo.ui.note(_("resolving manifests\n")) repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") % (overwrite, branchmerge, bool(partial))) - repo.ui.debug(_(" ancestor %s local %s remote %s\n") % - (short(p1), short(p2), short(pa))) + repo.ui.debug(_(" ancestor %s local %s remote %s\n") % (p1, p2, pa)) action = [] copy = {} @@ -369,7 +368,7 @@ def update(repo, node, branchmerge=False if not branchmerge: action += forgetremoved(m2, status) if not (backwards or overwrite): - copy = findcopies(repo, m1, m2, repo.changelog.rev(pa)) + copy = findcopies(repo, m1, m2, pa.rev()) action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards) del m1, m2, ma @@ -378,10 +377,10 @@ def update(repo, node, branchmerge=False if not branchmerge: # we don't need to do any magic, just jump to the new rev - p1, p2 = p2, nullid + p1, p2 = p2, repo.changectx(nullid) - xp1, xp2 = hex(p1), hex(p2) - if p2 == nullid: xp2 = '' + xp1, xp2 = str(p1), str(p2) + if p2.node() == nullid: xp2 = '' repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) @@ -389,7 +388,7 @@ def update(repo, node, branchmerge=False # update dirstate if not partial: - repo.dirstate.setparents(p1, p2) + repo.dirstate.setparents(p1.node(), p2.node()) recordupdates(repo, action, branchmerge) if show_stats: @@ -406,8 +405,7 @@ def update(repo, node, branchmerge=False " you can redo the full merge using:\n" " hg update -C %s\n" " hg merge %s\n" - % (repo.changelog.rev(p1), - repo.changelog.rev(p2)))) + % (p1.rev(), p2.rev()))) elif remind: repo.ui.status(_("(branch merge, don't forget to commit)\n")) elif unresolved: diff --git a/tests/test-hook.out b/tests/test-hook.out --- a/tests/test-hook.out +++ b/tests/test-hook.out @@ -62,10 +62,10 @@ precommit hook: p1=8ea2ef7ad3e8cac946c72 precommit.forbid hook abort: precommit.forbid hook exited with status 1 4:8ea2ef7ad3e8 -preupdate hook: p1=b702efe9688826e3a91283852b328b84dbf37bc2 p2= +preupdate hook: p1=b702efe96888 p2= 0 files updated, 0 files merged, 2 files removed, 0 files unresolved -preupdate hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2= -update hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2= err=0 +preupdate hook: p1=8ea2ef7ad3e8 p2= +update hook: p1=8ea2ef7ad3e8 p2= err=0 2 files updated, 0 files merged, 0 files removed, 0 files unresolved 3:4c52fb2e4022 prechangegroup.forbid hook