##// END OF EJS Templates
shrink-revlog: improve performance: use changegroup instead of revisions...
Benoit Boissinot -
r10009:69dca857 default
parent child Browse files
Show More
@@ -20,6 +20,7 b' parent revision. This is *not* safe to '
20 import sys, os, tempfile
20 import sys, os, tempfile
21 import optparse
21 import optparse
22 from mercurial import ui as ui_, hg, revlog, transaction, node, util
22 from mercurial import ui as ui_, hg, revlog, transaction, node, util
23 from mercurial import changegroup
23
24
24 def toposort(rl):
25 def toposort(rl):
25 write = sys.stdout.write
26 write = sys.stdout.write
@@ -73,18 +74,23 b' def toposort(rl):'
73 def writerevs(r1, r2, order, tr):
74 def writerevs(r1, r2, order, tr):
74 write = sys.stdout.write
75 write = sys.stdout.write
75 write('writing %d revs ' % len(order))
76 write('writing %d revs ' % len(order))
77
78 count = [0]
79 def progress(*args):
80 if count[0] % 1000 == 0:
81 write('.')
82 count[0] += 1
83
84 order = [r1.node(r) for r in order]
85
86 # this is a bit ugly, but it works
87 lookup = lambda x: "%020d" % r1.linkrev(r1.rev(x))
88 unlookup = lambda x: int(x, 10)
89
76 try:
90 try:
77 count = 0
91 group = util.chunkbuffer(r1.group(order, lookup, progress))
78 for rev in order:
92 chunkiter = changegroup.chunkiter(group)
79 n = r1.node(rev)
93 r2.addgroup(chunkiter, unlookup, tr)
80 p1, p2 = r1.parents(n)
81 l = r1.linkrev(rev)
82 t = r1.revision(n)
83 n2 = r2.addrevision(t, tr, l, p1, p2)
84
85 if count % 1000 == 0:
86 write('.')
87 count += 1
88 finally:
94 finally:
89 write('\n')
95 write('\n')
90
96
General Comments 0
You need to be logged in to leave comments. Login now