changeset 42383:3a3592b40a95

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 23 May 2019 14:02:01 +0200
parents f0bcbbb6541c
children f5f0a9490c05
files contrib/perf.py
diffstat 1 files changed, 20 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- 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