# HG changeset patch # User Pierre-Yves David # Date 2019-05-23 12:02:01 # 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 --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -963,16 +963,12 @@ def perfdirstatewrite(ui, repo, **opts): 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 @@ def perfmergecalculate(ui, repo, rev, ** # 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