comparison mercurial/copies.py @ 39263:eebd591803ab

copies: correctly skip directories that have already been considered Previously, `if dsrc in invalid` would never be true, since we added `dsrc +"/"` to invalid, not `dsrc` itself. Since it's much more common for individual files (not whole directories) to be moved, it seemed cleaner to delay appending the "/" until we know we have some directory moves to actually consider. I haven't benchmarked this, but I imagine this is a mild performance win. Differential Revision: https://phab.mercurial-scm.org/D4284
author Kyle Lippincott <spectral@google.com>
date Wed, 15 Aug 2018 14:41:27 -0700
parents fbec9c0b32d3
children a41497b5117c
comparison
equal deleted inserted replaced
39262:5b9f116104f9 39263:eebd591803ab
591 if dsrc in invalid: 591 if dsrc in invalid:
592 # already seen to be uninteresting 592 # already seen to be uninteresting
593 continue 593 continue
594 elif dsrc in d1 and ddst in d1: 594 elif dsrc in d1 and ddst in d1:
595 # directory wasn't entirely moved locally 595 # directory wasn't entirely moved locally
596 invalid.add(dsrc + "/") 596 invalid.add(dsrc)
597 elif dsrc in d2 and ddst in d2: 597 elif dsrc in d2 and ddst in d2:
598 # directory wasn't entirely moved remotely 598 # directory wasn't entirely moved remotely
599 invalid.add(dsrc + "/") 599 invalid.add(dsrc)
600 elif dsrc + "/" in dirmove and dirmove[dsrc + "/"] != ddst + "/": 600 elif dsrc in dirmove and dirmove[dsrc] != ddst:
601 # files from the same directory moved to two different places 601 # files from the same directory moved to two different places
602 invalid.add(dsrc + "/") 602 invalid.add(dsrc)
603 else: 603 else:
604 # looks good so far 604 # looks good so far
605 dirmove[dsrc + "/"] = ddst + "/" 605 dirmove[dsrc] = ddst
606 606
607 for i in invalid: 607 for i in invalid:
608 if i in dirmove: 608 if i in dirmove:
609 del dirmove[i] 609 del dirmove[i]
610 del d1, d2, invalid 610 del d1, d2, invalid
611 611
612 if not dirmove: 612 if not dirmove:
613 return copy, {}, diverge, renamedelete, {} 613 return copy, {}, diverge, renamedelete, {}
614
615 dirmove = {k + "/": v + "/" for k, v in dirmove.iteritems()}
614 616
615 for d in dirmove: 617 for d in dirmove:
616 repo.ui.debug(" discovered dir src: '%s' -> dst: '%s'\n" % 618 repo.ui.debug(" discovered dir src: '%s' -> dst: '%s'\n" %
617 (d, dirmove[d])) 619 (d, dirmove[d]))
618 620