##// END OF EJS Templates
merge: use repo.parents and parent contexts in update
Matt Mackall -
r3167:e67c22bc default
parent child Browse files
Show More
@@ -320,12 +320,12 b' def update(repo, node, branchmerge=False'
320
320
321 ### check phase
321 ### check phase
322
322
323 pl = repo.dirstate.parents()
323 pl = repo.parents()
324 if not overwrite and pl[1] != nullid:
324 if not overwrite and len(pl) > 1:
325 raise util.Abort(_("outstanding uncommitted merges"))
325 raise util.Abort(_("outstanding uncommitted merges"))
326
326
327 p1, p2 = pl[0], node
327 p1, p2 = pl[0], repo.changectx(node)
328 pa = repo.changelog.ancestor(p1, p2)
328 pa = p1.ancestor(p2)
329
329
330 # are we going backwards?
330 # are we going backwards?
331 backwards = (pa == p2)
331 backwards = (pa == p2)
@@ -345,17 +345,16 b' def update(repo, node, branchmerge=False'
345 if modified or added or removed:
345 if modified or added or removed:
346 raise util.Abort(_("outstanding uncommitted changes"))
346 raise util.Abort(_("outstanding uncommitted changes"))
347
347
348 m1 = repo.changectx(p1).manifest().copy()
348 m1 = p1.manifest().copy()
349 m2 = repo.changectx(p2).manifest().copy()
349 m2 = p2.manifest().copy()
350 ma = repo.changectx(pa).manifest()
350 ma = pa.manifest()
351
351
352 # resolve the manifest to determine which files
352 # resolve the manifest to determine which files
353 # we care about merging
353 # we care about merging
354 repo.ui.note(_("resolving manifests\n"))
354 repo.ui.note(_("resolving manifests\n"))
355 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") %
355 repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") %
356 (overwrite, branchmerge, bool(partial)))
356 (overwrite, branchmerge, bool(partial)))
357 repo.ui.debug(_(" ancestor %s local %s remote %s\n") %
357 repo.ui.debug(_(" ancestor %s local %s remote %s\n") % (p1, p2, pa))
358 (short(p1), short(p2), short(pa)))
359
358
360 action = []
359 action = []
361 copy = {}
360 copy = {}
@@ -369,7 +368,7 b' def update(repo, node, branchmerge=False'
369 if not branchmerge:
368 if not branchmerge:
370 action += forgetremoved(m2, status)
369 action += forgetremoved(m2, status)
371 if not (backwards or overwrite):
370 if not (backwards or overwrite):
372 copy = findcopies(repo, m1, m2, repo.changelog.rev(pa))
371 copy = findcopies(repo, m1, m2, pa.rev())
373
372
374 action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards)
373 action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards)
375 del m1, m2, ma
374 del m1, m2, ma
@@ -378,10 +377,10 b' def update(repo, node, branchmerge=False'
378
377
379 if not branchmerge:
378 if not branchmerge:
380 # we don't need to do any magic, just jump to the new rev
379 # we don't need to do any magic, just jump to the new rev
381 p1, p2 = p2, nullid
380 p1, p2 = p2, repo.changectx(nullid)
382
381
383 xp1, xp2 = hex(p1), hex(p2)
382 xp1, xp2 = str(p1), str(p2)
384 if p2 == nullid: xp2 = ''
383 if p2.node() == nullid: xp2 = ''
385
384
386 repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2)
385 repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2)
387
386
@@ -389,7 +388,7 b' def update(repo, node, branchmerge=False'
389
388
390 # update dirstate
389 # update dirstate
391 if not partial:
390 if not partial:
392 repo.dirstate.setparents(p1, p2)
391 repo.dirstate.setparents(p1.node(), p2.node())
393 recordupdates(repo, action, branchmerge)
392 recordupdates(repo, action, branchmerge)
394
393
395 if show_stats:
394 if show_stats:
@@ -406,8 +405,7 b' def update(repo, node, branchmerge=False'
406 " you can redo the full merge using:\n"
405 " you can redo the full merge using:\n"
407 " hg update -C %s\n"
406 " hg update -C %s\n"
408 " hg merge %s\n"
407 " hg merge %s\n"
409 % (repo.changelog.rev(p1),
408 % (p1.rev(), p2.rev())))
410 repo.changelog.rev(p2))))
411 elif remind:
409 elif remind:
412 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
410 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
413 elif unresolved:
411 elif unresolved:
@@ -62,10 +62,10 b' precommit hook: p1=8ea2ef7ad3e8cac946c72'
62 precommit.forbid hook
62 precommit.forbid hook
63 abort: precommit.forbid hook exited with status 1
63 abort: precommit.forbid hook exited with status 1
64 4:8ea2ef7ad3e8
64 4:8ea2ef7ad3e8
65 preupdate hook: p1=b702efe9688826e3a91283852b328b84dbf37bc2 p2=
65 preupdate hook: p1=b702efe96888 p2=
66 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
66 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
67 preupdate hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2=
67 preupdate hook: p1=8ea2ef7ad3e8 p2=
68 update hook: p1=8ea2ef7ad3e8cac946c72f1e0c79d6aebc301198 p2= err=0
68 update hook: p1=8ea2ef7ad3e8 p2= err=0
69 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
69 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 3:4c52fb2e4022
70 3:4c52fb2e4022
71 prechangegroup.forbid hook
71 prechangegroup.forbid hook
General Comments 0
You need to be logged in to leave comments. Login now