upgrade: use progress helper
authorMartin von Zweigbergk <martinvonz@google.com>
Sun, 17 Jun 2018 23:48:23 -0700
changeset 38399 185588cb0c4b
parent 38398 f273b768b60f
child 38400 2f5c622fcb73
upgrade: use progress helper A minor side-effect is that we no longer print the progress at 0 (and that we don't re-print it at its current value when starting the next manifest/file). Differential Revision: https://phab.mercurial-scm.org/D3800
mercurial/upgrade.py
--- a/mercurial/upgrade.py	Sun Jun 17 23:49:27 2018 -0700
+++ b/mercurial/upgrade.py	Sun Jun 17 23:48:23 2018 -0700
@@ -498,10 +498,9 @@
              (util.bytecount(srcsize), util.bytecount(srcrawsize))))
 
     # Used to keep track of progress.
-    progress = []
+    progress = None
     def oncopiedrevision(rl, rev, node):
-        progress[1] += 1
-        srcrepo.ui.progress(progress[0], progress[1], total=progress[2])
+        progress.increment()
 
     # Do the actual copying.
     # FUTURE this operation can be farmed off to worker processes.
@@ -523,7 +522,8 @@
                      (crevcount, util.bytecount(csrcsize),
                       util.bytecount(crawsize)))
             seen.add('c')
-            progress[:] = [_('changelog revisions'), 0, crevcount]
+            progress = srcrepo.ui.makeprogress(_('changelog revisions'),
+                                               total=crevcount)
         elif isinstance(oldrl, manifest.manifestrevlog) and 'm' not in seen:
             ui.write(_('finished migrating %d filelog revisions across %d '
                        'filelogs; change in size: %s\n') %
@@ -535,8 +535,9 @@
                       util.bytecount(mrawsize)))
             seen.add('m')
             if progress:
-                ui.progress(progress[0], None)
-            progress[:] = [_('manifest revisions'), 0, mrevcount]
+                progress.complete()
+            progress = srcrepo.ui.makeprogress(_('manifest revisions'),
+                                               total=mrevcount)
         elif 'f' not in seen:
             ui.write(_('migrating %d filelogs containing %d revisions '
                        '(%s in store; %s tracked data)\n') %
@@ -544,10 +545,10 @@
                       util.bytecount(frawsize)))
             seen.add('f')
             if progress:
-                ui.progress(progress[0], None)
-            progress[:] = [_('file revisions'), 0, frevcount]
+                progress.complete()
+            progress = srcrepo.ui.makeprogress(_('file revisions'),
+                                               total=frevcount)
 
-        ui.progress(progress[0], progress[1], total=progress[2])
 
         ui.note(_('cloning %d revisions from %s\n') % (len(oldrl), unencoded))
         oldrl.clone(tr, newrl, addrevisioncb=oncopiedrevision,
@@ -568,7 +569,7 @@
         else:
             fdstsize += datasize
 
-    ui.progress(progress[0], None)
+    progress.complete()
 
     ui.write(_('finished migrating %d changelog revisions; change in size: '
                '%s\n') % (crevcount, util.bytecount(cdstsize - csrcsize)))