Patchwork D763: copytrace: add a a new config to limit the number of drafts in heuristics

login
register
mail settings
Submitter phabricator
Date Sept. 21, 2017, 4:37 p.m.
Message ID <ef5f730111688ddfcc6842fba987816b@localhost.localdomain>
Download mbox | patch
Permalink /patch/24084/
State Not Applicable
Headers show

Comments

phabricator - Sept. 21, 2017, 4:37 p.m.
pulkit updated this revision to Diff 1967.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D763?vs=1961&id=1967

REVISION DETAIL
  https://phab.mercurial-scm.org/D763

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -376,22 +376,29 @@ 
         # Do full copytracing if only drafts are involved as that will be fast
         # enough and will also cover the copies which can be missed by
         # heuristics
-        if _isfullcopytraceable(c1, base):
+        if _isfullcopytraceable(repo.ui, c1, base):
             return _fullcopytracing(repo, c1, c2, base)
         return _heuristicscopytracing(repo, c1, c2, base)
     else:
         return _fullcopytracing(repo, c1, c2, base)
 
-def _isfullcopytraceable(c1, base):
+def _isfullcopytraceable(ui, c1, base):
     """ Checks that if base, source and destination are all draft branches, if
     yes let's use the full copytrace algorithm for increased capabilities since
     it will be fast enough.
     """
 
     nonpublicphases = set([phases.draft, phases.secret])
 
     if (c1.phase() in nonpublicphases) and (base.phase() in nonpublicphases):
-        return True
+        ctx = c1
+        commits = 0
+        sourcecommitlimit = ui.configint('experimental',
+                                        'copytrace.sourcecommitlimit', 100)
+        while ctx != base and commits != sourcecommitlimit:
+            ctx = ctx.p1()
+            commits += 1
+        return commits < sourcecommitlimit
     return False
 
 def _fullcopytracing(repo, c1, c2, base):