changeset 11135:73a4ed3bfef8

convert: add progress support
author Patrick Mezard <pmezard@gmail.com>
date Sun, 09 May 2010 22:50:07 +0200
parents 33010ff1fd6f
children ecc8b18736da
files hgext/convert/convcmd.py tests/test-convert-svn-move tests/test-convert-svn-move.out
diffstat 3 files changed, 46 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/convcmd.py	Sun May 09 21:52:34 2010 +0200
+++ b/hgext/convert/convcmd.py	Sun May 09 22:50:07 2010 +0200
@@ -111,11 +111,13 @@
             if n in known or n in self.map:
                 continue
             known.add(n)
+            self.ui.progress(_('scanning'), len(known), unit=_('revisions'))
             commit = self.cachecommit(n)
             parents[n] = []
             for p in commit.parents:
                 parents[n].append(p)
                 visit.append(p)
+        self.ui.progress(_('scanning'), None)
 
         return parents
 
@@ -321,7 +323,7 @@
             c = None
 
             self.ui.status(_("converting...\n"))
-            for c in t:
+            for i, c in enumerate(t):                
                 num -= 1
                 desc = self.commitcache[c].desc
                 if "\n" in desc:
@@ -331,7 +333,10 @@
                 # 'utf-8'
                 self.ui.status("%d %s\n" % (num, recode(desc)))
                 self.ui.note(_("source: %s\n") % recode(c))
+                self.ui.progress(_('converting'), i, unit=_('revisions'),
+                                 total=len(t))
                 self.copy(c)
+            self.ui.progress(_('converting'), None)
 
             tags = self.source.gettags()
             ctags = {}
--- a/tests/test-convert-svn-move	Sun May 09 21:52:34 2010 +0200
+++ b/tests/test-convert-svn-move	Sun May 09 22:50:07 2010 +0200
@@ -51,3 +51,20 @@
 echo '% try updating'
 hg up -qC default
 cd ..
+
+echo '% test convert progress bar'
+
+echo "progress=" >> $HGRCPATH
+echo "[progress]" >> $HGRCPATH
+echo "assume-tty=1" >> $HGRCPATH
+echo "delay=0" >> $HGRCPATH
+echo "refresh=0" >> $HGRCPATH
+
+cat > filtercr.py <<EOF
+import sys, re
+for line in sys.stdin:
+    line = re.sub(r'\r+[^\n]', lambda m: '\n' + m.group()[-1:], line)
+    sys.stdout.write(line)
+EOF
+
+hg convert svn-repo hg-progress 2>&1 | python filtercr.py
--- a/tests/test-convert-svn-move.out	Sun May 09 21:52:34 2010 +0200
+++ b/tests/test-convert-svn-move.out	Sun May 09 22:50:07 2010 +0200
@@ -80,3 +80,26 @@
 644 @ dlink2
 644 @ dlink3
 % try updating
+% test convert progress bar
+
+scanning [ <=>                                                              ] 1
+scanning [  <=>                                                             ] 2
+scanning [   <=>                                                            ] 3
+scanning [    <=>                                                           ] 4
+                                                                                
+converting [                                                              ] 0/4
+                                                                                
+converting [==============>                                               ] 1/4
+                                                                                
+converting [==============================>                               ] 2/4
+                                                                                
+converting [=============================================>                ] 3/4
+                                                                                
+initializing destination hg-progress repository
+scanning source...
+sorting...
+converting...
+3 initial
+2 clobber symlink
+1 clobber1
+0 clobber2