[PATCH 1 of 6] shrink-revlog: instrument sort code to record statistics
Greg Ward
greg-hg at gerg.ca
Sun Mar 7 12:57:56 CST 2010
# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1267985644 18000
# Node ID 0ecd19db21d1c0b22971da9234ef37cc8d8bd316
# Parent 94145b531cf97bb8002781a0aa02b0e4d2eefe73
shrink-revlog: instrument sort code to record statistics.
Notably, count "suboptimal" nodes (predecessor is not first parent)
and 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,8 @@
if len(parents_unseen) == 0:
next.append(c)
visit = next + visit
+ ui.write('\n')
+ ui.write('%d suboptimal nodes\n' % suboptimal)
return ret
def writerevs(ui, r1, r2, order, tr):
More information about the Mercurial-devel
mailing list