Show More
@@ -374,10 +374,10 b' def mergecopies(repo, c1, c2, base):' | |||||
374 | bothnew = sorted(addedinm1 & addedinm2) |
|
374 | bothnew = sorted(addedinm1 & addedinm2) | |
375 |
|
375 | |||
376 | for f in u1u: |
|
376 | for f in u1u: | |
377 | _checkcopies(c1, f, m1, m2, base, limit, data1) |
|
377 | _checkcopies(c1, f, m1, m2, base, tca, limit, data1) | |
378 |
|
378 | |||
379 | for f in u2u: |
|
379 | for f in u2u: | |
380 | _checkcopies(c2, f, m2, m1, base, limit, data2) |
|
380 | _checkcopies(c2, f, m2, m1, base, tca, limit, data2) | |
381 |
|
381 | |||
382 | copy = dict(data1['copy'].items() + data2['copy'].items()) |
|
382 | copy = dict(data1['copy'].items() + data2['copy'].items()) | |
383 | fullcopy = dict(data1['fullcopy'].items() + data2['fullcopy'].items()) |
|
383 | fullcopy = dict(data1['fullcopy'].items() + data2['fullcopy'].items()) | |
@@ -405,8 +405,8 b' def mergecopies(repo, c1, c2, base):' | |||||
405 | 'diverge': bothdiverge, |
|
405 | 'diverge': bothdiverge, | |
406 | } |
|
406 | } | |
407 | for f in bothnew: |
|
407 | for f in bothnew: | |
408 | _checkcopies(c1, f, m1, m2, base, limit, bothdata) |
|
408 | _checkcopies(c1, f, m1, m2, base, tca, limit, bothdata) | |
409 | _checkcopies(c2, f, m2, m1, base, limit, bothdata) |
|
409 | _checkcopies(c2, f, m2, m1, base, tca, limit, bothdata) | |
410 | for of, fl in bothdiverge.items(): |
|
410 | for of, fl in bothdiverge.items(): | |
411 | if len(fl) == 2 and fl[0] == fl[1]: |
|
411 | if len(fl) == 2 and fl[0] == fl[1]: | |
412 | copy[fl[0]] = of # not actually divergent, just matching renames |
|
412 | copy[fl[0]] = of # not actually divergent, just matching renames | |
@@ -521,7 +521,7 b' def _related(f1, f2, limit):' | |||||
521 | except StopIteration: |
|
521 | except StopIteration: | |
522 | return False |
|
522 | return False | |
523 |
|
523 | |||
524 | def _checkcopies(ctx, f, m1, m2, base, limit, data): |
|
524 | def _checkcopies(ctx, f, m1, m2, base, tca, limit, data): | |
525 | """ |
|
525 | """ | |
526 | check possible copies of f from m1 to m2 |
|
526 | check possible copies of f from m1 to m2 | |
527 |
|
527 | |||
@@ -530,6 +530,7 b' def _checkcopies(ctx, f, m1, m2, base, l' | |||||
530 | m1 = the source manifest |
|
530 | m1 = the source manifest | |
531 | m2 = the destination manifest |
|
531 | m2 = the destination manifest | |
532 | base = the changectx used as a merge base |
|
532 | base = the changectx used as a merge base | |
|
533 | tca = topological common ancestor for graft-like scenarios | |||
533 | limit = the rev number to not search beyond |
|
534 | limit = the rev number to not search beyond | |
534 | data = dictionary of dictionary to store copy data. (see mergecopies) |
|
535 | data = dictionary of dictionary to store copy data. (see mergecopies) | |
535 |
|
536 | |||
@@ -540,6 +541,17 b' def _checkcopies(ctx, f, m1, m2, base, l' | |||||
540 | """ |
|
541 | """ | |
541 |
|
542 | |||
542 | mb = base.manifest() |
|
543 | mb = base.manifest() | |
|
544 | # Might be true if this call is about finding backward renames, | |||
|
545 | # This happens in the case of grafts because the DAG is then rotated. | |||
|
546 | # If the file exists in both the base and the source, we are not looking | |||
|
547 | # for a rename on the source side, but on the part of the DAG that is | |||
|
548 | # traversed backwards. | |||
|
549 | # | |||
|
550 | # In the case there is both backward and forward renames (before and after | |||
|
551 | # the base) this is more complicated as we must detect a divergence. This | |||
|
552 | # is currently broken and hopefully some later code update will make that | |||
|
553 | # work (we use 'backwards = False' in that case) | |||
|
554 | backwards = base != tca and f in mb | |||
543 | getfctx = _makegetfctx(ctx) |
|
555 | getfctx = _makegetfctx(ctx) | |
544 |
|
556 | |||
545 | of = None |
|
557 | of = None | |
@@ -554,7 +566,11 b' def _checkcopies(ctx, f, m1, m2, base, l' | |||||
554 | continue |
|
566 | continue | |
555 | seen.add(of) |
|
567 | seen.add(of) | |
556 |
|
568 | |||
557 |
|
|
569 | # remember for dir rename detection | |
|
570 | if backwards: | |||
|
571 | data['fullcopy'][of] = f # grafting backwards through renames | |||
|
572 | else: | |||
|
573 | data['fullcopy'][f] = of | |||
558 | if of not in m2: |
|
574 | if of not in m2: | |
559 | continue # no match, keep looking |
|
575 | continue # no match, keep looking | |
560 | if m2[of] == mb.get(of): |
|
576 | if m2[of] == mb.get(of): | |
@@ -562,9 +578,11 b' def _checkcopies(ctx, f, m1, m2, base, l' | |||||
562 | c2 = getfctx(of, m2[of]) |
|
578 | c2 = getfctx(of, m2[of]) | |
563 | # c2 might be a plain new file on added on destination side that is |
|
579 | # c2 might be a plain new file on added on destination side that is | |
564 | # unrelated to the droids we are looking for. |
|
580 | # unrelated to the droids we are looking for. | |
565 |
cr = _related(oc, c2, |
|
581 | cr = _related(oc, c2, tca.rev()) | |
566 | if cr and (of == f or of == c2.path()): # non-divergent |
|
582 | if cr and (of == f or of == c2.path()): # non-divergent | |
567 |
if |
|
583 | if backwards: | |
|
584 | data['copy'][of] = f | |||
|
585 | elif of in mb: | |||
568 | data['copy'][f] = of |
|
586 | data['copy'][f] = of | |
569 | return |
|
587 | return | |
570 |
|
588 |
General Comments 0
You need to be logged in to leave comments.
Login now