[PATCH 6 of 9 V3] perf: add `parent-2` as possible source for perfrevlogwrite

Boris Feld boris.feld at octobus.net
Tue Nov 6 06:27:34 EST 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1541427318 -3600
#      Mon Nov 05 15:15:18 2018 +0100
# Node ID cb7f6cc58b0e41617189b4c473a17f309bb598b5
# Parent  934e67cf46a673a89aac27a846977c808b23e071
# EXP-Topic revlog-perf
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r cb7f6cc58b0e
perf: add `parent-2` as possible source for perfrevlogwrite

This source will use a diff against p2 if it exists and fall back to p1
otherwise.

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1581,6 +1581,8 @@ def perfrevlogwrite(ui, repo, file_=None
     Possible source value are:
     * `full`: add from a full text (default).
     * `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)
     """
     opts = _byteskwargs(opts)
 
@@ -1592,7 +1594,7 @@ def perfrevlogwrite(ui, repo, file_=None
         stoprev = rllen + stoprev
 
     source = opts['source']
-    validsource = (b'full', b'parent-1')
+    validsource = (b'full', b'parent-1', b'parent-2')
     if source not in validsource:
         raise error.Abort('invalid source type: %s' % source)
 
@@ -1685,6 +1687,8 @@ def _timeonewrite(ui, orig, source, star
     return timings
 
 def _getrevisionseed(orig, rev, tr, source):
+    from mercurial.node import nullid
+
     linkrev = orig.linkrev(rev)
     node = orig.node(rev)
     p1, p2 = orig.parents(node)
@@ -1697,6 +1701,12 @@ def _getrevisionseed(orig, rev, tr, sour
     elif source == b'parent-1':
         baserev = orig.rev(p1)
         cachedelta = (baserev, orig.revdiff(p1, rev))
+    elif source == b'parent-2':
+        parent = p2
+        if p2 == nullid:
+            parent = p1
+        baserev = orig.rev(parent)
+        cachedelta = (baserev, orig.revdiff(parent, rev))
 
     return ((text, tr, linkrev, p1, p2),
             {'node': node, 'flags':flags, 'cachedelta': cachedelta})


More information about the Mercurial-devel mailing list