Patchwork [7,of,9,V3] perf: add `parent-smallest` as possible source for perfrevlogwrite

login
register
mail settings
Submitter Boris Feld
Date Nov. 6, 2018, 11:27 a.m.
Message ID <0c64116c5e5da0c6cece.1541503655@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/36421/
State Accepted
Headers show

Comments

Boris Feld - Nov. 6, 2018, 11:27 a.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1541427584 -3600
#      Mon Nov 05 15:19:44 2018 +0100
# Node ID 0c64116c5e5da0c6cece45a68ff1fa2fec2318ba
# Parent  cb7f6cc58b0e41617189b4c473a17f309bb598b5
# EXP-Topic revlog-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0c64116c5e5d
perf: add `parent-smallest` as possible source for perfrevlogwrite

This source will use the smallest of the possible diff against parent.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1583,6 +1583,7 @@  def perfrevlogwrite(ui, repo, file_=None
     * `parent-1`: add from a delta to the first parent
     * `parent-2`: add from a delta to the second parent if it exists
                   (use a delta from the first parent otherwise)
+    * `parent-smallest`: add from the smallest delta (either p1 or p2)
     """
     opts = _byteskwargs(opts)
 
@@ -1594,7 +1595,7 @@  def perfrevlogwrite(ui, repo, file_=None
         stoprev = rllen + stoprev
 
     source = opts['source']
-    validsource = (b'full', b'parent-1', b'parent-2')
+    validsource = (b'full', b'parent-1', b'parent-2', b'parent-smallest')
     if source not in validsource:
         raise error.Abort('invalid source type: %s' % source)
 
@@ -1707,6 +1708,17 @@  def _getrevisionseed(orig, rev, tr, sour
             parent = p1
         baserev = orig.rev(parent)
         cachedelta = (baserev, orig.revdiff(parent, rev))
+    elif source == b'parent-smallest':
+        p1diff = orig.revdiff(p1, rev)
+        parent = p1
+        diff = p1diff
+        if p2 != nullid:
+            p2diff = orig.revdiff(p2, rev)
+            if len(p1diff) > len(p2diff):
+                parent = p2
+                diff = p2diff
+        baserev = orig.rev(parent)
+        cachedelta = (baserev, diff)
 
     return ((text, tr, linkrev, p1, p2),
             {'node': node, 'flags':flags, 'cachedelta': cachedelta})