[PATCH 1 of 5] shrink-revlog: instrument sort code to record statistics

Greg Ward greg-hg at gerg.ca
Tue Mar 9 20:32:26 CST 2010


# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1268187219 18000
# Node ID 1ee14abe07b4bb1a557a06fe52fe500ec8549dfd
# Parent  bcdf376805694da77760049b49622bc439e9b18f
shrink-revlog: instrument sort code to record statistics.

Notably, count "suboptimal" nodes (predecessor is not first parent)
and (with -v) report them at the end of the run.

diff --git a/contrib/shrink-revlog.py b/contrib/shrink-revlog.py
--- a/contrib/shrink-revlog.py
+++ b/contrib/shrink-revlog.py
@@ -53,8 +53,19 @@
     ui.status(_('sorting revs\n'))
     visit = root
     ret = []
+
+    # suboptimal: nodes whose predecessor is not first parent
+    suboptimal = 0
+
     while visit:
         i = visit.pop(0)
+        # revlog will compute delta relative to ret[-1], so keep track
+        # of nodes where this might result in a large delta
+        parents = rl.parentrevs(i)
+        if ret:
+            if ret[-1] != parents[0]:
+                suboptimal += 1
+
         ret.append(i)
         if i not in children:
             # This only happens if some node's p1 == p2, which can
@@ -67,6 +78,7 @@
             if len(parents_unseen) == 0:
                 next.append(c)
         visit = next + visit
+    ui.note(_('%d suboptimal nodes\n') % suboptimal)
     return ret
 
 def writerevs(ui, r1, r2, order, tr):


More information about the Mercurial-devel mailing list