comparison contrib/shrink-revlog.py @ 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 989b2a5eaaba
children c93f0a23f381
comparison
equal deleted inserted replaced
10619:bcdf37680569 10620:1ee14abe07b4
51 # algorithm in hgext.convert.convcmd... would be nice not to duplicate 51 # algorithm in hgext.convert.convcmd... would be nice not to duplicate
52 # the algorithm 52 # the algorithm
53 ui.status(_('sorting revs\n')) 53 ui.status(_('sorting revs\n'))
54 visit = root 54 visit = root
55 ret = [] 55 ret = []
56
57 # suboptimal: nodes whose predecessor is not first parent
58 suboptimal = 0
59
56 while visit: 60 while visit:
57 i = visit.pop(0) 61 i = visit.pop(0)
62 # revlog will compute delta relative to ret[-1], so keep track
63 # of nodes where this might result in a large delta
64 parents = rl.parentrevs(i)
65 if ret:
66 if ret[-1] != parents[0]:
67 suboptimal += 1
68
58 ret.append(i) 69 ret.append(i)
59 if i not in children: 70 if i not in children:
60 # This only happens if some node's p1 == p2, which can 71 # This only happens if some node's p1 == p2, which can
61 # happen in the manifest in certain circumstances. 72 # happen in the manifest in certain circumstances.
62 continue 73 continue
65 parents_unseen = [p for p in rl.parentrevs(c) 76 parents_unseen = [p for p in rl.parentrevs(c)
66 if p != node.nullrev and p in children] 77 if p != node.nullrev and p in children]
67 if len(parents_unseen) == 0: 78 if len(parents_unseen) == 0:
68 next.append(c) 79 next.append(c)
69 visit = next + visit 80 visit = next + visit
81 ui.note(_('%d suboptimal nodes\n') % suboptimal)
70 return ret 82 return ret
71 83
72 def writerevs(ui, r1, r2, order, tr): 84 def writerevs(ui, r1, r2, order, tr):
73 85
74 ui.status(_('writing revs\n')) 86 ui.status(_('writing revs\n'))