equal
deleted
inserted
replaced
15 |
15 |
16 from . import ( |
16 from . import ( |
17 match as matchmod, |
17 match as matchmod, |
18 pathutil, |
18 pathutil, |
19 policy, |
19 policy, |
20 pycompat, |
|
21 util, |
20 util, |
22 ) |
21 ) |
23 |
22 |
24 |
23 |
25 from .utils import stringutil |
24 from .utils import stringutil |
66 |
65 |
67 |
66 |
68 def _chain(prefix, suffix): |
67 def _chain(prefix, suffix): |
69 """chain two sets of copies 'prefix' and 'suffix'""" |
68 """chain two sets of copies 'prefix' and 'suffix'""" |
70 result = prefix.copy() |
69 result = prefix.copy() |
71 for key, value in pycompat.iteritems(suffix): |
70 for key, value in suffix.items(): |
72 result[key] = prefix.get(value, value) |
71 result[key] = prefix.get(value, value) |
73 return result |
72 return result |
74 |
73 |
75 |
74 |
76 def _tracefile(fctx, am, basemf): |
75 def _tracefile(fctx, am, basemf): |
406 elif parent == 2: |
405 elif parent == 2: |
407 childcopies = changes.copied_from_p2 |
406 childcopies = changes.copied_from_p2 |
408 |
407 |
409 if childcopies: |
408 if childcopies: |
410 newcopies = copies.copy() |
409 newcopies = copies.copy() |
411 for dest, source in pycompat.iteritems(childcopies): |
410 for dest, source in childcopies.items(): |
412 prev = copies.get(source) |
411 prev = copies.get(source) |
413 if prev is not None and prev[1] is not None: |
412 if prev is not None and prev[1] is not None: |
414 source = prev[1] |
413 source = prev[1] |
415 newcopies[dest] = (current_rev, source) |
414 newcopies[dest] = (current_rev, source) |
416 assert newcopies is not copies |
415 assert newcopies is not copies |
621 dst: src for dst, src in childcopies.items() if match(dst) |
620 dst: src for dst, src in childcopies.items() if match(dst) |
622 } |
621 } |
623 newcopies = copies |
622 newcopies = copies |
624 if childcopies: |
623 if childcopies: |
625 newcopies = copies.copy() |
624 newcopies = copies.copy() |
626 for dest, source in pycompat.iteritems(childcopies): |
625 for dest, source in childcopies.items(): |
627 prev = copies.get(source) |
626 prev = copies.get(source) |
628 if prev is not None and prev[1] is not None: |
627 if prev is not None and prev[1] is not None: |
629 source = prev[1] |
628 source = prev[1] |
630 newcopies[dest] = (c, source) |
629 newcopies[dest] = (c, source) |
631 assert newcopies is not copies |
630 assert newcopies is not copies |
719 """given copies to context 'dst', finds renames from that context""" |
718 """given copies to context 'dst', finds renames from that context""" |
720 # Even though we're not taking copies into account, 1:n rename situations |
719 # Even though we're not taking copies into account, 1:n rename situations |
721 # can still exist (e.g. hg cp a b; hg mv a c). In those cases we |
720 # can still exist (e.g. hg cp a b; hg mv a c). In those cases we |
722 # arbitrarily pick one of the renames. |
721 # arbitrarily pick one of the renames. |
723 r = {} |
722 r = {} |
724 for k, v in sorted(pycompat.iteritems(copies)): |
723 for k, v in sorted(copies.items()): |
725 if match and not match(v): |
724 if match and not match(v): |
726 continue |
725 continue |
727 # remove copies |
726 # remove copies |
728 if v in dst: |
727 if v in dst: |
729 continue |
728 continue |
1078 invalid = set() |
1077 invalid = set() |
1079 dirmove = {} |
1078 dirmove = {} |
1080 |
1079 |
1081 # examine each file copy for a potential directory move, which is |
1080 # examine each file copy for a potential directory move, which is |
1082 # when all the files in a directory are moved to a new directory |
1081 # when all the files in a directory are moved to a new directory |
1083 for dst, src in pycompat.iteritems(fullcopy): |
1082 for dst, src in fullcopy.items(): |
1084 dsrc, ddst = pathutil.dirname(src), pathutil.dirname(dst) |
1083 dsrc, ddst = pathutil.dirname(src), pathutil.dirname(dst) |
1085 if dsrc in invalid: |
1084 if dsrc in invalid: |
1086 # already seen to be uninteresting |
1085 # already seen to be uninteresting |
1087 continue |
1086 continue |
1088 elif ctx.hasdir(dsrc) and ctx.hasdir(ddst): |
1087 elif ctx.hasdir(dsrc) and ctx.hasdir(ddst): |
1101 del invalid |
1100 del invalid |
1102 |
1101 |
1103 if not dirmove: |
1102 if not dirmove: |
1104 return {}, {} |
1103 return {}, {} |
1105 |
1104 |
1106 dirmove = {k + b"/": v + b"/" for k, v in pycompat.iteritems(dirmove)} |
1105 dirmove = {k + b"/": v + b"/" for k, v in dirmove.items()} |
1107 |
1106 |
1108 for d in dirmove: |
1107 for d in dirmove: |
1109 repo.ui.debug( |
1108 repo.ui.debug( |
1110 b" discovered dir src: '%s' -> dst: '%s'\n" % (d, dirmove[d]) |
1109 b" discovered dir src: '%s' -> dst: '%s'\n" % (d, dirmove[d]) |
1111 ) |
1110 ) |
1184 changedfiles.update(ctx.files()) |
1183 changedfiles.update(ctx.files()) |
1185 ctx = ctx.p1() |
1184 ctx = ctx.p1() |
1186 |
1185 |
1187 copies2 = {} |
1186 copies2 = {} |
1188 cp = _forwardcopies(base, c2) |
1187 cp = _forwardcopies(base, c2) |
1189 for dst, src in pycompat.iteritems(cp): |
1188 for dst, src in cp.items(): |
1190 if src in m1: |
1189 if src in m1: |
1191 copies2[dst] = src |
1190 copies2[dst] = src |
1192 |
1191 |
1193 # file is missing if it isn't present in the destination, but is present in |
1192 # file is missing if it isn't present in the destination, but is present in |
1194 # the base and present in the source. |
1193 # the base and present in the source. |
1302 # would result in the creation of an empty commit where we would prefer to |
1301 # would result in the creation of an empty commit where we would prefer to |
1303 # not create one. |
1302 # not create one. |
1304 for dest, __ in list(new_copies.items()): |
1303 for dest, __ in list(new_copies.items()): |
1305 if dest in parent: |
1304 if dest in parent: |
1306 del new_copies[dest] |
1305 del new_copies[dest] |
1307 for dst, src in pycompat.iteritems(new_copies): |
1306 for dst, src in new_copies.items(): |
1308 wctx[dst].markcopied(src) |
1307 wctx[dst].markcopied(src) |