##// 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 20 import sys, os, tempfile
21 21 import optparse
22 22 from mercurial import ui as ui_, hg, revlog, transaction, node, util
23 from mercurial import changegroup
23 24
24 25 def toposort(rl):
25 26 write = sys.stdout.write
@@ -73,18 +74,23 b' def toposort(rl):'
73 74 def writerevs(r1, r2, order, tr):
74 75 write = sys.stdout.write
75 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 90 try:
77 count = 0
78 for rev in order:
79 n = r1.node(rev)
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
91 group = util.chunkbuffer(r1.group(order, lookup, progress))
92 chunkiter = changegroup.chunkiter(group)
93 r2.addgroup(chunkiter, unlookup, tr)
88 94 finally:
89 95 write('\n')
90 96
General Comments 0
You need to be logged in to leave comments. Login now