# HG changeset patch # User Benoit Boissinot # Date 1266071684 -3600 # Node ID b39b32c33269a92d0f4a50508eadd8b91b34f907 # Parent 509f4ed56509bdc79663d71cce81e9f56aeb6095 shrink: use progress API diff -r 509f4ed56509 -r b39b32c33269 contrib/shrink-revlog.py --- a/contrib/shrink-revlog.py Sat Feb 13 09:55:28 2010 +0100 +++ b/contrib/shrink-revlog.py Sat Feb 13 15:34:44 2010 +0100 @@ -29,9 +29,10 @@ children = {} root = [] # build children and roots - ui.write('reading %d revs ' % len(rl)) + ui.status('reading revs\n') try: for i in rl: + ui.progress('reading', i, total=len(rl)) children[i] = [] parents = [p for p in rl.parentrevs(i) if p != node.nullrev] # in case of duplicate parents @@ -43,16 +44,13 @@ if len(parents) == 0: root.append(i) - - if i % 1000 == 0: - ui.write('.') finally: - ui.write('\n') + ui.progress('reading', None, total=len(rl)) # XXX this is a reimplementation of the 'branchsort' topo sort # algorithm in hgext.convert.convcmd... would be nice not to duplicate # the algorithm - ui.write('sorting ...') + ui.status('sorting revs\n') visit = root ret = [] while visit: @@ -69,16 +67,15 @@ if len(parents_unseen) == 0: next.append(c) visit = next + visit - ui.write('\n') return ret def writerevs(ui, r1, r2, order, tr): - ui.write('writing %d revs ' % len(order)) + ui.status('writing revs\n') + count = [0] def progress(*args): - if count[0] % 1000 == 0: - ui.write('.') + ui.progress('writing', count[0], total=len(order)) count[0] += 1 order = [r1.node(r) for r in order] @@ -92,7 +89,7 @@ chunkiter = changegroup.chunkiter(group) r2.addgroup(chunkiter, unlookup, tr) finally: - ui.write('\n') + ui.progress('writing', None, len(order)) def report(ui, olddatafn, newdatafn): oldsize = float(os.stat(olddatafn).st_size)