Patchwork D3808: largefiles: use progress helper

login
register
mail settings
Submitter phabricator
Date June 19, 2018, 11:18 a.m.
Message ID <6eb89af43235ccb47949572a309c2100@localhost.localdomain>
Download mbox | patch
Permalink /patch/32326/
State Not Applicable
Headers show

Comments

phabricator - June 19, 2018, 11:18 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG164306d3f4b4: largefiles: use progress helper (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3808?vs=9210&id=9224

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

AFFECTED FILES
  hgext/largefiles/basestore.py
  hgext/largefiles/lfcommands.py
  hgext/largefiles/lfutil.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -501,9 +501,10 @@ 
     return filelist
 
 def getlfilestoupload(repo, missing, addfunc):
+    progress = repo.ui.makeprogress(_('finding outgoing largefiles'),
+                                    unit=_('revisions'), total=len(missing))
     for i, n in enumerate(missing):
-        repo.ui.progress(_('finding outgoing largefiles'), i,
-            unit=_('revisions'), total=len(missing))
+        progress.update(i)
         parents = [p for p in repo[n].parents() if p != node.nullid]
 
         oldlfstatus = repo.lfstatus
@@ -530,7 +531,7 @@ 
         for fn in files:
             if isstandin(fn) and fn in ctx:
                 addfunc(fn, readasstandin(ctx[fn]))
-    repo.ui.progress(_('finding outgoing largefiles'), None)
+    progress.complete()
 
 def updatestandinsbymatch(repo, match):
     '''Update standins in the working directory according to specified match
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -118,12 +118,14 @@ 
                 matcher = None
 
             lfiletohash = {}
+            progress = ui.makeprogress(_('converting revisions'),
+                                       unit=_('revisions'),
+                                       total=rsrc['tip'].rev())
             for ctx in ctxs:
-                ui.progress(_('converting revisions'), ctx.rev(),
-                    unit=_('revisions'), total=rsrc['tip'].rev())
+                progress.update(ctx.rev())
                 _lfconvert_addchangeset(rsrc, rdst, ctx, revmap,
                     lfiles, normalfiles, matcher, size, lfiletohash)
-            ui.progress(_('converting revisions'), None)
+            progress.complete()
 
             if rdst.wvfs.exists(lfutil.shortname):
                 rdst.wvfs.rmtree(lfutil.shortname)
@@ -368,17 +370,18 @@ 
     files = [h for h in files if not retval[h]]
     ui.debug("%d largefiles need to be uploaded\n" % len(files))
 
+    progress = ui.makeprogress(_('uploading largefiles'), unit=_('files'),
+                               total=len(files))
     for hash in files:
-        ui.progress(_('uploading largefiles'), at, unit=_('files'),
-                    total=len(files))
+        progress.update(at)
         source = lfutil.findfile(rsrc, hash)
         if not source:
             raise error.Abort(_('largefile %s missing from store'
                                ' (needs to be uploaded)') % hash)
         # XXX check for errors here
         store.put(source, hash)
         at += 1
-    ui.progress(_('uploading largefiles'), None)
+    progress.complete()
 
 def verifylfiles(ui, repo, all=False, contents=False):
     '''Verify that every largefile revision in the current changeset
diff --git a/hgext/largefiles/basestore.py b/hgext/largefiles/basestore.py
--- a/hgext/largefiles/basestore.py
+++ b/hgext/largefiles/basestore.py
@@ -62,9 +62,10 @@ 
 
         at = 0
         available = self.exists(set(hash for (_filename, hash) in files))
+        progress = ui.makeprogress(_('getting largefiles'), unit=_('files'),
+                                   total=len(files))
         for filename, hash in files:
-            ui.progress(_('getting largefiles'), at, unit=_('files'),
-                total=len(files))
+            progress.update(at)
             at += 1
             ui.note(_('getting %s:%s\n') % (filename, hash))
 
@@ -79,7 +80,7 @@ 
             else:
                 missing.append(filename)
 
-        ui.progress(_('getting largefiles'), None)
+        progress.complete()
         return (success, missing)
 
     def _gethash(self, filename, hash):