##// END OF EJS Templates
checkcopies: extract the '_related' closure...
Pierre-Yves David -
r30138:733fb9f7 default
parent child Browse files
Show More
@@ -454,6 +454,40 b' def mergecopies(repo, c1, c2, ca):'
454
454
455 return copy, movewithdir, diverge, renamedelete
455 return copy, movewithdir, diverge, renamedelete
456
456
457 def _related(f1, f2, limit):
458 """return True if f1 and f2 filectx have a common ancestor
459
460 Walk back to common ancestor to see if the two files originate
461 from the same file. Since workingfilectx's rev() is None it messes
462 up the integer comparison logic, hence the pre-step check for
463 None (f1 and f2 can only be workingfilectx's initially).
464 """
465
466 if f1 == f2:
467 return f1 # a match
468
469 g1, g2 = f1.ancestors(), f2.ancestors()
470 try:
471 f1r, f2r = f1.linkrev(), f2.linkrev()
472
473 if f1r is None:
474 f1 = next(g1)
475 if f2r is None:
476 f2 = next(g2)
477
478 while True:
479 f1r, f2r = f1.linkrev(), f2.linkrev()
480 if f1r > f2r:
481 f1 = next(g1)
482 elif f2r > f1r:
483 f2 = next(g2)
484 elif f1 == f2:
485 return f1 # a match
486 elif f1r == f2r or f1r < limit or f2r < limit:
487 return False # copy no longer relevant
488 except StopIteration:
489 return False
490
457 def _checkcopies(ctx, f, m1, m2, base, limit, diverge, copy, fullcopy):
491 def _checkcopies(ctx, f, m1, m2, base, limit, diverge, copy, fullcopy):
458 """
492 """
459 check possible copies of f from m1 to m2
493 check possible copies of f from m1 to m2
@@ -477,37 +511,6 b' def _checkcopies(ctx, f, m1, m2, base, l'
477 mb = base.manifest()
511 mb = base.manifest()
478 getfctx = _makegetfctx(ctx)
512 getfctx = _makegetfctx(ctx)
479
513
480 def _related(f1, f2, limit):
481 # Walk back to common ancestor to see if the two files originate
482 # from the same file. Since workingfilectx's rev() is None it messes
483 # up the integer comparison logic, hence the pre-step check for
484 # None (f1 and f2 can only be workingfilectx's initially).
485
486 if f1 == f2:
487 return f1 # a match
488
489 g1, g2 = f1.ancestors(), f2.ancestors()
490 try:
491 f1r, f2r = f1.linkrev(), f2.linkrev()
492
493 if f1r is None:
494 f1 = next(g1)
495 if f2r is None:
496 f2 = next(g2)
497
498 while True:
499 f1r, f2r = f1.linkrev(), f2.linkrev()
500 if f1r > f2r:
501 f1 = next(g1)
502 elif f2r > f1r:
503 f2 = next(g2)
504 elif f1 == f2:
505 return f1 # a match
506 elif f1r == f2r or f1r < limit or f2r < limit:
507 return False # copy no longer relevant
508 except StopIteration:
509 return False
510
511 of = None
514 of = None
512 seen = set([f])
515 seen = set([f])
513 for oc in getfctx(f, m1[f]).ancestors():
516 for oc in getfctx(f, m1[f]).ancestors():
General Comments 0
You need to be logged in to leave comments. Login now