mercurial/similar.py
changeset 31588 2e254165a37c
parent 31587 b1528d195a13
child 31589 2efd9771323e
equal deleted inserted replaced
31587:b1528d195a13 31588:2e254165a37c
    91 
    91 
    92     for dest, v in copies.iteritems():
    92     for dest, v in copies.iteritems():
    93         source, bscore = v
    93         source, bscore = v
    94         yield source, dest, bscore
    94         yield source, dest, bscore
    95 
    95 
       
    96 def _dropempty(fctxs):
       
    97     return [x for x in fctxs if x.size() > 0]
       
    98 
    96 def findrenames(repo, added, removed, threshold):
    99 def findrenames(repo, added, removed, threshold):
    97     '''find renamed files -- yields (before, after, score) tuples'''
   100     '''find renamed files -- yields (before, after, score) tuples'''
    98     wctx = repo[None]
   101     wctx = repo[None]
    99     pctx = wctx.p1()
   102     pctx = wctx.p1()
   100 
   103 
   101     # Zero length files will be frequently unrelated to each other, and
   104     # Zero length files will be frequently unrelated to each other, and
   102     # tracking the deletion/addition of such a file will probably cause more
   105     # tracking the deletion/addition of such a file will probably cause more
   103     # harm than good. We strip them out here to avoid matching them later on.
   106     # harm than good. We strip them out here to avoid matching them later on.
   104     addedfiles = [wctx[fp] for fp in sorted(added)
   107     addedfiles = _dropempty(wctx[fp] for fp in sorted(added))
   105                   if wctx[fp].size() > 0]
   108     removedfiles = _dropempty(pctx[fp] for fp in sorted(removed) if fp in pctx)
   106     removedfiles = [pctx[fp] for fp in sorted(removed)
       
   107                     if fp in pctx and pctx[fp].size() > 0]
       
   108 
   109 
   109     # Find exact matches.
   110     # Find exact matches.
   110     matchedfiles = set()
   111     matchedfiles = set()
   111     for (a, b) in _findexactmatches(repo, addedfiles, removedfiles):
   112     for (a, b) in _findexactmatches(repo, addedfiles, removedfiles):
   112         matchedfiles.add(b)
   113         matchedfiles.add(b)