Patchwork D3800: upgrade: use progress helper

login
register
mail settings
Submitter phabricator
Date June 18, 2018, 5:15 p.m.
Message ID <differential-rev-PHID-DREV-kf6cyl7mp672sdgbton5-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32298/
State Superseded
Headers show

Comments

phabricator - June 18, 2018, 5:15 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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).

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3800

AFFECTED FILES
  mercurial/upgrade.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -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,19 +535,20 @@ 
                       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') %
                      (fcount, frevcount, util.bytecount(fsrcsize),
                       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)))