perf: factor selection of revisions involved in the merge out
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 23 May 2019 14:02:01 +0200
changeset 42383 3a3592b40a95
parent 42382 f0bcbbb6541c
child 42384 f5f0a9490c05
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.
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