changeset 10440:b39b32c33269

shrink: use progress API
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Sat, 13 Feb 2010 15:34:44 +0100
parents 509f4ed56509
children dc0d1ca2d378
files contrib/shrink-revlog.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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)