mercurial/copies.py
changeset 34846 f05a6e015ecc
parent 34787 754b5117622f
child 35420 7ddc1e96d9b0
equal deleted inserted replaced
34845:78d9a7b7cdb6 34846:f05a6e015ecc
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 import collections
    10 import collections
    11 import heapq
    11 import heapq
    12 import os
    12 import os
       
    13 
       
    14 from .i18n import _
    13 
    15 
    14 from . import (
    16 from . import (
    15     match as matchmod,
    17     match as matchmod,
    16     node,
    18     node,
    17     pathutil,
    19     pathutil,
   642 
   644 
   643     Can be used by setting the following config:
   645     Can be used by setting the following config:
   644 
   646 
   645         [experimental]
   647         [experimental]
   646         copytrace = heuristics
   648         copytrace = heuristics
       
   649 
       
   650     In some cases the copy/move candidates found by heuristics can be very large
       
   651     in number and that will make the algorithm slow. The number of possible
       
   652     candidates to check can be limited by using the config
       
   653     `experimental.copytrace.movecandidateslimit` which defaults to 100.
   647     """
   654     """
   648 
   655 
   649     if c1.rev() is None:
   656     if c1.rev() is None:
   650         c1 = c1.p1()
   657         c1 = c1.p1()
   651     if c2.rev() is None:
   658     if c2.rev() is None:
   702             samedirname = dirnametofilename[dirname]
   709             samedirname = dirnametofilename[dirname]
   703             movecandidates = samebasename + samedirname
   710             movecandidates = samebasename + samedirname
   704             # f is guaranteed to be present in c2, that's why
   711             # f is guaranteed to be present in c2, that's why
   705             # c2.filectx(f) won't fail
   712             # c2.filectx(f) won't fail
   706             f2 = c2.filectx(f)
   713             f2 = c2.filectx(f)
       
   714             # we can have a lot of candidates which can slow down the heuristics
       
   715             # config value to limit the number of candidates moves to check
       
   716             maxcandidates = repo.ui.configint('experimental',
       
   717                                               'copytrace.movecandidateslimit')
       
   718 
       
   719             if len(movecandidates) > maxcandidates:
       
   720                 repo.ui.status(_("skipping copytracing for '%s', more "
       
   721                                  "candidates than the limit: %d\n")
       
   722                                % (f, len(movecandidates)))
       
   723                 continue
       
   724 
   707             for candidate in movecandidates:
   725             for candidate in movecandidates:
   708                 f1 = c1.filectx(candidate)
   726                 f1 = c1.filectx(candidate)
   709                 if _related(f1, f2, anc.rev()):
   727                 if _related(f1, f2, anc.rev()):
   710                     # if there are a few related copies then we'll merge
   728                     # if there are a few related copies then we'll merge
   711                     # changes into all of them. This matches the behaviour
   729                     # changes into all of them. This matches the behaviour