D4416: copies: improve logic of deciding copytracing on based of config options

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Aug 29 16:31:52 UTC 2018


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

REVISION SUMMARY
  Few months ago or maybe a year ago, I imported Fb's heuristics based copytracing
  algorithms. While importing that, I renamed `experimental.disablecopytrace` with
  `experimental.copytrace` and the behavior of the new config option was like
  this:
  
  - "heuristics" : Fb's heuristic copytracing algorithm
  - "off" : copytracing is turned off
  - something else: copytracing is on
  
  This is the behavior right now also and this is bad because it hardcodes the
  string 'off' to turn off the copytracing. On big repositories, copytracing is
  very slow and people wants to turn copytracing off. However if the user sets it
  to 'False', 'Off', '0', none of them is going to disbale copytracing while they
  should.
  I lacked the understanding of why this can be bad when I coded it.
  
  After this patch, the new behavior of the config option will be:
  
  - "heuristics": Fb's heuristic copytracing algorithm
  - '0', 'false', 'off', 'never', 'no', 'NO', all the values which repo.ui.configbool() evaluates to False: copytracing in turned off
  - something else: copytracing is on
  
  Since 'off' still evaluates to copytracing being turned off, this is not BC.
  Also the config option is experimental.

REPOSITORY
  rHG Mercurial

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

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
@@ -365,20 +365,18 @@
     if c2.node() is None and c1.node() == repo.dirstate.p1():
         return repo.dirstate.copies(), {}, {}, {}, {}
 
-    copytracing = repo.ui.config('experimental', 'copytrace')
-
     # Copy trace disabling is explicitly below the node == p1 logic above
     # because the logic above is required for a simple copy to be kept across a
     # rebase.
-    if copytracing == 'off':
-        return {}, {}, {}, {}, {}
-    elif copytracing == 'heuristics':
+    if repo.ui.config('experimental', 'copytrace') == 'heuristics':
         # Do full copytracing if only non-public revisions are involved as
         # that will be fast enough and will also cover the copies which could
         # be missed by heuristics
         if _isfullcopytraceable(repo, c1, base):
             return _fullcopytracing(repo, c1, c2, base)
         return _heuristicscopytracing(repo, c1, c2, base)
+    elif not repo.ui.configbool('experimental', 'copytrace'):
+        return {}, {}, {}, {}, {}
     else:
         return _fullcopytracing(repo, c1, c2, base)
 
@@ -871,7 +869,8 @@
     """
     exclude = {}
     if (skiprev is not None and
-        repo.ui.config('experimental', 'copytrace') != 'off'):
+        (repo.ui.config('experimental', 'copytrace') == 'heuristics' or
+         repo.ui.configbool('experimental', 'copytrace'))):
         # copytrace='off' skips this line, but not the entire function because
         # the line below is O(size of the repo) during a rebase, while the rest
         # of the function is much faster (and is required for carrying copy



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


More information about the Mercurial-devel mailing list