318 if not wlock: |
318 if not wlock: |
319 wlock = repo.wlock() |
319 wlock = repo.wlock() |
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) |
332 |
332 |
333 # is there a linear path from p1 to p2? |
333 # is there a linear path from p1 to p2? |
343 modified, added, removed, deleted, unknown = status[:5] |
343 modified, added, removed, deleted, unknown = status[:5] |
344 if branchmerge and not forcemerge: |
344 if branchmerge and not forcemerge: |
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 = {} |
362 |
361 |
363 m1 = workingmanifest(repo, m1, status) |
362 m1 = workingmanifest(repo, m1, status) |
367 if not force: |
366 if not force: |
368 checkunknown(repo, m2, status) |
367 checkunknown(repo, m2, status) |
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 |
376 |
375 |
377 ### apply phase |
376 ### apply phase |
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 |
388 updated, merged, removed, unresolved = applyupdates(repo, action, xp1, xp2) |
387 updated, merged, removed, unresolved = applyupdates(repo, action, xp1, xp2) |
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: |
396 stats = ((updated, _("updated")), |
395 stats = ((updated, _("updated")), |
397 (merged - unresolved, _("merged")), |
396 (merged - unresolved, _("merged")), |
404 if unresolved: |
403 if unresolved: |
405 repo.ui.status(_("There are unresolved merges," |
404 repo.ui.status(_("There are unresolved merges," |
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: |
414 repo.ui.status(_("There are unresolved merges with" |
412 repo.ui.status(_("There are unresolved merges with" |
415 " locally modified files.\n")) |
413 " locally modified files.\n")) |