This is an archive of the discontinued Mercurial Phabricator instance.

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

Authored by pulkit on Aug 29 2018, 12:31 PM.

Details

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

pulkit created this revision.Aug 29 2018, 12:31 PM
yuja added a subscriber: yuja.Aug 29 2018, 6:55 PM

check-config complains about bool vs str. parsebool() might help.

pulkit updated this revision to Diff 10677.Aug 30 2018, 8:57 AM
yuja added a comment.Aug 30 2018, 9:33 AM

Queued, thanks.

+ elif boolctrace is False:
+ # stringutil.parsebool() returns None when it is unable to parse the
+ # value, so we should rely on making sure copytracing is on such cases

Yep. Maybe we can add a helper function that returns truthy value if
copytracing is somewhat on.

v = ui.config('experimental', 'copytrace')
if parsebool(v) is False:
    return None
return v
This revision was automatically updated to reflect the committed changes.