##// END OF EJS Templates
checkcopies: extract the '_related' closure...
Pierre-Yves David -
r30138:733fb9f7 default
parent child Browse files
Show More
@@ -454,35 +454,15 def mergecopies(repo, c1, c2, ca):
454
454
455 return copy, movewithdir, diverge, renamedelete
455 return copy, movewithdir, diverge, renamedelete
456
456
457 def _checkcopies(ctx, f, m1, m2, base, limit, diverge, copy, fullcopy):
457 def _related(f1, f2, limit):
458 """
458 """return True if f1 and f2 filectx have a common ancestor
459 check possible copies of f from m1 to m2
460
461 ctx = starting context for f in m1
462 f = the filename to check (as in m1)
463 m1 = the source manifest
464 m2 = the destination manifest
465 base = the changectx used as a merge base
466 limit = the rev number to not search beyond
467 diverge = record all diverges in this dict
468 copy = record all non-divergent copies in this dict
469 fullcopy = record all copies in this dict
470
459
471 note: limit is only an optimization, and there is no guarantee that
460 Walk back to common ancestor to see if the two files originate
472 irrelevant revisions will not be limited
461 from the same file. Since workingfilectx's rev() is None it messes
473 there is no easy way to make this algorithm stop in a guaranteed way
462 up the integer comparison logic, hence the pre-step check for
474 once it "goes behind a certain revision".
463 None (f1 and f2 can only be workingfilectx's initially).
475 """
464 """
476
465
477 mb = base.manifest()
478 getfctx = _makegetfctx(ctx)
479
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:
466 if f1 == f2:
487 return f1 # a match
467 return f1 # a match
488
468
@@ -508,6 +488,29 def _checkcopies(ctx, f, m1, m2, base, l
508 except StopIteration:
488 except StopIteration:
509 return False
489 return False
510
490
491 def _checkcopies(ctx, f, m1, m2, base, limit, diverge, copy, fullcopy):
492 """
493 check possible copies of f from m1 to m2
494
495 ctx = starting context for f in m1
496 f = the filename to check (as in m1)
497 m1 = the source manifest
498 m2 = the destination manifest
499 base = the changectx used as a merge base
500 limit = the rev number to not search beyond
501 diverge = record all diverges in this dict
502 copy = record all non-divergent copies in this dict
503 fullcopy = record all copies in this dict
504
505 note: limit is only an optimization, and there is no guarantee that
506 irrelevant revisions will not be limited
507 there is no easy way to make this algorithm stop in a guaranteed way
508 once it "goes behind a certain revision".
509 """
510
511 mb = base.manifest()
512 getfctx = _makegetfctx(ctx)
513
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