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

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu Sep 21 12:19:22 UTC 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The heuristics options tries to the default full copytracing algorithm if both
  the source and destination branches contains of non-public changesets only. But
  this can be slow in cases when we have a lot of drafts.
  
  This patch adds a new config option experimental.copytrace.sourcecommitlimit
  which defaults to 100. This value will be the limit of number of drafts from c1
  to base. Incase there are more changesets even though they are draft, the
  heuristics algorithm will be used.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS

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(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):



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


More information about the Mercurial-devel mailing list