changeset 11136:ecc8b18736da

convert: display files data retrieval progress
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 May 2010 22:50:42 +0200
parents 73a4ed3bfef8
children 94afe7bc87a9
files hgext/convert/convcmd.py tests/test-convert-svn-move.out
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/convcmd.py	Sun May 09 22:50:07 2010 +0200
+++ b/hgext/convert/convcmd.py	Sun May 09 22:50:42 2010 +0200
@@ -72,6 +72,25 @@
             ui.note(_("convert: %s\n") % inst)
     raise util.Abort(_('%s: unknown repository type') % path)
 
+class progresssource(object):
+    def __init__(self, ui, source, filecount):
+        self.ui = ui
+        self.source = source
+        self.filecount = filecount
+        self.retrieved = 0
+
+    def getfile(self, file, rev):
+        self.retrieved += 1
+        self.ui.progress(_('retrieving file'), self.retrieved,
+                         item=file, total=self.filecount)
+        return self.source.getfile(file, rev)
+
+    def lookuprev(self, rev):
+        return self.source.lookuprev(rev)
+
+    def close(self):
+        self.ui.progress(_('retrieving file'), None)
+
 class converter(object):
     def __init__(self, ui, source, dest, revmapfile, opts):
 
@@ -304,8 +323,10 @@
             parents = [self.map.get(p, p) for p in parents]
         except KeyError:
             parents = [b[0] for b in pbranches]
+        source = progresssource(self.ui, self.source, len(files))
         newnode = self.dest.putcommit(files, copies, parents, commit,
-                                      self.source, self.map)
+                                      source, self.map)
+        source.close()
         self.source.converted(rev, newnode)
         self.map[rev] = newnode
 
--- a/tests/test-convert-svn-move.out	Sun May 09 22:50:07 2010 +0200
+++ b/tests/test-convert-svn-move.out	Sun May 09 22:50:42 2010 +0200
@@ -88,12 +88,23 @@
 scanning [    <=>                                                           ] 4
                                                                                 
 converting [                                                              ] 0/4
+retrieving file [==========>                                              ] 1/5
+retrieving file [=====================>                                   ] 2/5
+retrieving file [=================================>                       ] 3/5
+retrieving file [============================================>            ] 4/5
+retrieving file [========================================================>] 5/5
                                                                                 
 converting [==============>                                               ] 1/4
+retrieving file [========================================================>] 1/1
                                                                                 
 converting [==============================>                               ] 2/4
+retrieving file [=============>                                           ] 1/4
+retrieving file [===========================>                             ] 2/4
+retrieving file [=========================================>               ] 3/4
+retrieving file [========================================================>] 4/4
                                                                                 
 converting [=============================================>                ] 3/4
+retrieving file [========================================================>] 1/1
                                                                                 
 initializing destination hg-progress repository
 scanning source...