Patchwork D3780: subrepo: use progress helper

login
register
mail settings
Submitter phabricator
Date June 18, 2018, 7:05 a.m.
Message ID <differential-rev-PHID-DREV-g6cd24lnxie74qsfsokj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/32242/
State Superseded
Headers show

Comments

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/subrepo.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -333,17 +333,17 @@ 
             files = self.files()
         total = len(files)
         relpath = subrelpath(self)
-        self.ui.progress(_('archiving (%s)') % relpath, 0,
-                         unit=_('files'), total=total)
-        for i, name in enumerate(files):
+        progress = self.ui.makeprogress(_('archiving (%s)') % relpath,
+                                        unit=_('files'), total=total)
+        progress.update(0)
+        for name in files:
             flags = self.fileflags(name)
             mode = 'x' in flags and 0o755 or 0o644
             symlink = 'l' in flags
             archiver.addfile(prefix + self._path + '/' + name,
                              mode, symlink, self.filedata(name, decode))
-            self.ui.progress(_('archiving (%s)') % relpath, i + 1,
-                             unit=_('files'), total=total)
-        self.ui.progress(_('archiving (%s)') % relpath, None)
+            progress.increment()
+        progress.complete()
         return total
 
     def walk(self, match):
@@ -1640,8 +1640,10 @@ 
         tarstream = self._gitcommand(['archive', revision], stream=True)
         tar = tarfile.open(fileobj=tarstream, mode=r'r|')
         relpath = subrelpath(self)
-        self.ui.progress(_('archiving (%s)') % relpath, 0, unit=_('files'))
-        for i, info in enumerate(tar):
+        progress = self.ui.makeprogress(_('archiving (%s)') % relpath,
+                                        unit=_('files'))
+        progress.update(0)
+        for info in tar:
             if info.isdir():
                 continue
             if match and not match(info.name):
@@ -1653,9 +1655,8 @@ 
             archiver.addfile(prefix + self._path + '/' + info.name,
                              info.mode, info.issym(), data)
             total += 1
-            self.ui.progress(_('archiving (%s)') % relpath, i + 1,
-                             unit=_('files'))
-        self.ui.progress(_('archiving (%s)') % relpath, None)
+            progress.increment()
+        progress.complete()
         return total