Patchwork [3,of,5] perf: factor selection of revisions involved in the merge out

login
register
mail settings
Submitter Pierre-Yves David
Date May 23, 2019, 4:47 p.m.
Message ID <1587f4e0cca53e0f6074.1558630077@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40215/
State Accepted
Headers show

Comments

Pierre-Yves David - May 23, 2019, 4:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1558612921 -7200
#      Thu May 23 14:02:01 2019 +0200
# Node ID 1587f4e0cca53e0f6074599c079b664461877dfb
# Parent  c5959a988d0d0142c62ab4a0bdd54732f18fc2c9
# EXP-Topic perf-mergecopies
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1587f4e0cca5
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 piece of `perfmergecalculate` that can be re be reused.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -922,16 +922,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]
@@ -940,19 +936,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