##// END OF EJS Templates
shrink: use progress API
Benoit Boissinot -
r10440:b39b32c3 default
parent child Browse files
Show More
@@ -29,9 +29,10 b' def toposort(ui, rl):'
29 children = {}
29 children = {}
30 root = []
30 root = []
31 # build children and roots
31 # build children and roots
32 ui.write('reading %d revs ' % len(rl))
32 ui.status('reading revs\n')
33 try:
33 try:
34 for i in rl:
34 for i in rl:
35 ui.progress('reading', i, total=len(rl))
35 children[i] = []
36 children[i] = []
36 parents = [p for p in rl.parentrevs(i) if p != node.nullrev]
37 parents = [p for p in rl.parentrevs(i) if p != node.nullrev]
37 # in case of duplicate parents
38 # in case of duplicate parents
@@ -43,16 +44,13 b' def toposort(ui, rl):'
43
44
44 if len(parents) == 0:
45 if len(parents) == 0:
45 root.append(i)
46 root.append(i)
46
47 if i % 1000 == 0:
48 ui.write('.')
49 finally:
47 finally:
50 ui.write('\n')
48 ui.progress('reading', None, total=len(rl))
51
49
52 # XXX this is a reimplementation of the 'branchsort' topo sort
50 # XXX this is a reimplementation of the 'branchsort' topo sort
53 # algorithm in hgext.convert.convcmd... would be nice not to duplicate
51 # algorithm in hgext.convert.convcmd... would be nice not to duplicate
54 # the algorithm
52 # the algorithm
55 ui.write('sorting ...')
53 ui.status('sorting revs\n')
56 visit = root
54 visit = root
57 ret = []
55 ret = []
58 while visit:
56 while visit:
@@ -69,16 +67,15 b' def toposort(ui, rl):'
69 if len(parents_unseen) == 0:
67 if len(parents_unseen) == 0:
70 next.append(c)
68 next.append(c)
71 visit = next + visit
69 visit = next + visit
72 ui.write('\n')
73 return ret
70 return ret
74
71
75 def writerevs(ui, r1, r2, order, tr):
72 def writerevs(ui, r1, r2, order, tr):
76
73
77 ui.write('writing %d revs ' % len(order))
74 ui.status('writing revs\n')
75
78 count = [0]
76 count = [0]
79 def progress(*args):
77 def progress(*args):
80 if count[0] % 1000 == 0:
78 ui.progress('writing', count[0], total=len(order))
81 ui.write('.')
82 count[0] += 1
79 count[0] += 1
83
80
84 order = [r1.node(r) for r in order]
81 order = [r1.node(r) for r in order]
@@ -92,7 +89,7 b' def writerevs(ui, r1, r2, order, tr):'
92 chunkiter = changegroup.chunkiter(group)
89 chunkiter = changegroup.chunkiter(group)
93 r2.addgroup(chunkiter, unlookup, tr)
90 r2.addgroup(chunkiter, unlookup, tr)
94 finally:
91 finally:
95 ui.write('\n')
92 ui.progress('writing', None, len(order))
96
93
97 def report(ui, olddatafn, newdatafn):
94 def report(ui, olddatafn, newdatafn):
98 oldsize = float(os.stat(olddatafn).st_size)
95 oldsize = float(os.stat(olddatafn).st_size)
General Comments 0
You need to be logged in to leave comments. Login now