changeset 10620:1ee14abe07b4

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.
author Greg Ward <greg-hg@gerg.ca>
date Tue, 09 Mar 2010 21:13:39 -0500
parents bcdf37680569
children c93f0a23f381
files contrib/shrink-revlog.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/shrink-revlog.py	Tue Mar 09 22:18:37 2010 +0100
+++ b/contrib/shrink-revlog.py	Tue Mar 09 21:13:39 2010 -0500
@@ -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):