# HG changeset patch # User Pierre-Yves David # Date 1558612921 -7200 # Node ID 3a3592b40a954abc9703e9f7fb103dc28f4c3894 # Parent f0bcbbb6541c26666016224f96fdeeb95f73bb46 perf: factor selection of revisions involved in the merge out We will introduce more performance command around merge. As a first step we factor out pieces of `perfmergecalculate` that can be reused. diff -r f0bcbbb6541c -r 3a3592b40a95 contrib/perf.py --- a/contrib/perf.py Thu May 23 13:49:31 2019 +0200 +++ b/contrib/perf.py Thu May 23 14:02:01 2019 +0200 @@ -963,16 +963,12 @@ timer(d) fm.end() -@command(b'perfmergecalculate', - [ - (b'r', b'rev', b'.', b'rev to merge against'), - (b'', b'from', b'', b'rev to merge from'), - (b'', b'base', b'', b'the revision to use as base'), - ] + formatteropts) -def perfmergecalculate(ui, repo, rev, **opts): - opts = _byteskwargs(opts) - timer, fm = gettimer(ui, opts) - +def _getmergerevs(repo, opts): + """parse command argument to return rev involved in merge + + input: options dictionnary with `rev`, `from` and `bse` + output: (localctx, otherctx, basectx) + """ if opts['from']: fromrev = scmutil.revsingle(repo, opts['from']) wctx = repo[fromrev] @@ -981,19 +977,25 @@ # we don't want working dir files to be stat'd in the benchmark, so # prime that cache wctx.dirty() - rctx = scmutil.revsingle(repo, rev, rev) + rctx = scmutil.revsingle(repo, opts['rev'], opts['rev']) if opts['base']: fromrev = scmutil.revsingle(repo, opts['base']) ancestor = repo[fromrev] else: ancestor = wctx.ancestor(rctx) - def d(): - # acceptremote is True because we don't want prompts in the middle of - # our benchmark - merge.calculateupdates(repo, wctx, rctx, [ancestor], False, False, - acceptremote=True, followcopies=True) - timer(d) - fm.end() + return (wctx, rctx, ancestor) + +@command(b'perfmergecalculate', + [ + (b'r', b'rev', b'.', b'rev to merge against'), + (b'', b'from', b'', b'rev to merge from'), + (b'', b'base', b'', b'the revision to use as base'), + ] + formatteropts) +def perfmergecalculate(ui, repo, **opts): + opts = _byteskwargs(opts) + timer, fm = gettimer(ui, opts) + + wctx, rctx, ancestor = _getmergerevs(repo, opts) def d(): # acceptremote is True because we don't want prompts in the middle of # our benchmark