332 def removeop(f, args): |
332 def removeop(f, args): |
333 pmmf.discard(f) |
333 pmmf.discard(f) |
334 def nop(f, args): |
334 def nop(f, args): |
335 pass |
335 pass |
336 |
336 |
337 def renameop(f, args): |
337 def renamemoveop(f, args): |
338 f2, fd, flags = args |
338 f2, flags = args |
339 if f: |
339 pmmf.discard(f2) |
340 pmmf.discard(f) |
340 pmmf.add(f) |
341 pmmf.add(fd) |
341 def renamegetop(f, args): |
|
342 f2, flags = args |
|
343 pmmf.add(f) |
342 def mergeop(f, args): |
344 def mergeop(f, args): |
343 f2, fa, fd, move, anc = args |
345 f2, fa, fd, move, anc = args |
344 if move: |
346 if move: |
345 pmmf.discard(f) |
347 pmmf.discard(f) |
346 pmmf.add(fd) |
348 pmmf.add(fd) |
347 |
349 |
348 opmap = { |
350 opmap = { |
349 "a": addop, |
351 "a": addop, |
350 "d": renameop, |
352 "dm": renamemoveop, |
|
353 "dg": renamegetop, |
351 "dr": nop, |
354 "dr": nop, |
352 "e": nop, |
355 "e": nop, |
353 "f": addop, # untracked file should be kept in working directory |
356 "f": addop, # untracked file should be kept in working directory |
354 "g": addop, |
357 "g": addop, |
355 "m": mergeop, |
358 "m": mergeop, |
470 else: # both changed something |
473 else: # both changed something |
471 actions.append((f, "m", (f, fa, f, False, pa.node()), |
474 actions.append((f, "m", (f, fa, f, False, pa.node()), |
472 "versions differ")) |
475 "versions differ")) |
473 elif f in copied: # files we'll deal with on m2 side |
476 elif f in copied: # files we'll deal with on m2 side |
474 pass |
477 pass |
475 elif n1 and f in movewithdir: # directory rename |
478 elif n1 and f in movewithdir: # directory rename, move local |
476 f2 = movewithdir[f] |
479 f2 = movewithdir[f] |
477 actions.append((f, "d", (None, f2, fl1), |
480 actions.append((f2, "dm", (f, fl1), |
478 "remote renamed directory to " + f2)) |
481 "remote directory rename - move from " + f)) |
479 elif n1 and f in copy: |
482 elif n1 and f in copy: |
480 f2 = copy[f] |
483 f2 = copy[f] |
481 actions.append((f, "m", (f2, f2, f, False, pa.node()), |
484 actions.append((f, "m", (f2, f2, f, False, pa.node()), |
482 "local copied/moved to " + f2)) |
485 "local copied/moved to " + f2)) |
483 elif n1 and f in ma: # clean, a different, no remote |
486 elif n1 and f in ma: # clean, a different, no remote |
490 actions.append((f, "f", None, "remote deleted")) |
493 actions.append((f, "f", None, "remote deleted")) |
491 else: |
494 else: |
492 actions.append((f, "r", None, "other deleted")) |
495 actions.append((f, "r", None, "other deleted")) |
493 elif n2 and f in movewithdir: |
496 elif n2 and f in movewithdir: |
494 f2 = movewithdir[f] |
497 f2 = movewithdir[f] |
495 actions.append((None, "d", (f, f2, fl2), |
498 actions.append((f2, "dg", (f, fl2), |
496 "local renamed directory to " + f2)) |
499 "local directory rename - get from " + f)) |
497 elif n2 and f in copy: |
500 elif n2 and f in copy: |
498 f2 = copy[f] |
501 f2 = copy[f] |
499 if f2 in m2: |
502 if f2 in m2: |
500 actions.append((f2, "m", (f, f2, f, False, pa.node()), |
503 actions.append((f2, "m", (f, f2, f, False, pa.node()), |
501 "remote copied to " + f)) |
504 "remote copied to " + f)) |
691 else: |
694 else: |
692 if r is None: |
695 if r is None: |
693 updated += 1 |
696 updated += 1 |
694 else: |
697 else: |
695 merged += 1 |
698 merged += 1 |
696 elif m == "d": # directory rename |
699 elif m == "dm": # directory rename, move local |
697 f2, fd, flags = args |
700 f0, flags = args |
698 if f: |
701 repo.ui.note(_("moving %s to %s\n") % (f0, f)) |
699 repo.ui.note(_("moving %s to %s\n") % (f, fd)) |
702 audit(f) |
700 audit(fd) |
703 repo.wwrite(f, wctx.filectx(f0).data(), flags) |
701 repo.wwrite(fd, wctx.filectx(f).data(), flags) |
704 util.unlinkpath(repo.wjoin(f0)) |
702 util.unlinkpath(repo.wjoin(f)) |
705 updated += 1 |
703 if f2: |
706 elif m == "dg": # local directory rename, get |
704 repo.ui.note(_("getting %s to %s\n") % (f2, fd)) |
707 f0, flags = args |
705 repo.wwrite(fd, mctx.filectx(f2).data(), flags) |
708 repo.ui.note(_("getting %s to %s\n") % (f0, f)) |
|
709 repo.wwrite(f, mctx.filectx(f0).data(), flags) |
706 updated += 1 |
710 updated += 1 |
707 elif m == "dr": # divergent renames |
711 elif m == "dr": # divergent renames |
708 fl, = args |
712 fl, = args |
709 repo.ui.warn(_("note: possible conflict - %s was renamed " |
713 repo.ui.warn(_("note: possible conflict - %s was renamed " |
710 "multiple times to:\n") % f) |
714 "multiple times to:\n") % f) |
809 # modification. |
813 # modification. |
810 if f2 == fd: # file not locally copied/moved |
814 if f2 == fd: # file not locally copied/moved |
811 repo.dirstate.normallookup(fd) |
815 repo.dirstate.normallookup(fd) |
812 if move: |
816 if move: |
813 repo.dirstate.drop(f) |
817 repo.dirstate.drop(f) |
814 elif m == "d": # directory rename |
818 elif m == "dm": # directory rename, move local |
815 f2, fd, flag = args |
819 f0, flag = args |
816 if not f2 and f not in repo.dirstate: |
820 if f0 not in repo.dirstate: |
817 # untracked file moved |
821 # untracked file moved |
818 continue |
822 continue |
819 if branchmerge: |
823 if branchmerge: |
820 repo.dirstate.add(fd) |
824 repo.dirstate.add(f) |
821 if f: |
825 repo.dirstate.remove(f0) |
822 repo.dirstate.remove(f) |
826 repo.dirstate.copy(f0, f) |
823 repo.dirstate.copy(f, fd) |
827 else: |
824 if f2: |
828 repo.dirstate.normal(f) |
825 repo.dirstate.copy(f2, fd) |
829 repo.dirstate.drop(f0) |
826 else: |
830 elif m == "dg": # directory rename, get |
827 repo.dirstate.normal(fd) |
831 f0, flag = args |
828 if f: |
832 if branchmerge: |
829 repo.dirstate.drop(f) |
833 repo.dirstate.add(f) |
|
834 repo.dirstate.copy(f0, f) |
|
835 else: |
|
836 repo.dirstate.normal(f) |
830 |
837 |
831 def update(repo, node, branchmerge, force, partial, ancestor=None, |
838 def update(repo, node, branchmerge, force, partial, ancestor=None, |
832 mergeancestor=False): |
839 mergeancestor=False): |
833 """ |
840 """ |
834 Perform a merge between the working directory and the given node |
841 Perform a merge between the working directory and the given node |