changeset 38379:3a7c33a2cc5e

subrepo: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3780
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 17 Jun 2018 22:09:15 -0700
parents e5d87c69bbcb
children 63e6f5ae84bc
files mercurial/subrepo.py
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/subrepo.py	Sun Jun 17 22:05:54 2018 -0700
+++ b/mercurial/subrepo.py	Sun Jun 17 22:09:15 2018 -0700
@@ -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