D3774: progress: hide update(None) in a new complete() method

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Mon Jun 18 07:05:19 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  update(None) seemed a bit cryptic.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/changegroup.py
  mercurial/cmdutil.py
  mercurial/merge.py
  mercurial/scmutil.py
  mercurial/setdiscovery.py
  mercurial/similar.py
  mercurial/streamclone.py

CHANGE DETAILS

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -321,7 +321,7 @@
             progress.increment(step=len(chunk))
             yield chunk
 
-        progress.update(None)
+        progress.complete()
 
     return requirements, gen()
 
@@ -384,7 +384,7 @@
         elapsed = util.timer() - start
         if elapsed <= 0:
             elapsed = 0.001
-        progress.update(None)
+        progress.complete()
         repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
                        (util.bytecount(bytecount), elapsed,
                         util.bytecount(bytecount / elapsed)))
@@ -526,7 +526,7 @@
                 finally:
                     fp.close()
         finally:
-            progress.update(None)
+            progress.complete()
 
 def generatev2(repo):
     """Emit content for version 2 of a streaming clone.
@@ -624,7 +624,7 @@
         repo.ui.status(_('transferred %s in %.1f seconds (%s/sec)\n') %
                        (util.bytecount(progress.pos), elapsed,
                         util.bytecount(progress.pos / elapsed)))
-        progress.update(None)
+        progress.complete()
 
 def applybundlev2(repo, fp, filecount, filesize, requirements):
     missingreqs = [r for r in requirements if r not in repo.supported]
diff --git a/mercurial/similar.py b/mercurial/similar.py
--- a/mercurial/similar.py
+++ b/mercurial/similar.py
@@ -44,7 +44,7 @@
                 break
 
     # Done
-    progress.update(None)
+    progress.complete()
 
 def _ctxdata(fctx):
     # lazily load text
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -252,7 +252,7 @@
     # return any heads in that case, so discard that
     result.discard(nullrev)
     elapsed = util.timer() - start
-    progress.update(None)
+    progress.complete()
     ui.debug("%d total queries in %.4fs\n" % (roundtrips, elapsed))
     msg = ('found %d common and %d unknown server heads,'
            ' %d roundtrips in %.4fs\n')
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1302,6 +1302,9 @@
     def increment(self, step=1, item="", total=None):
         self.update(self.pos + step, item, total)
 
+    def complete(self):
+        self.update(None)
+
     def _print(self, item):
         self.ui.progress(self.topic, self.pos, item, self.unit,
                          self.total)
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1785,7 +1785,7 @@
         actions[ACTION_MERGE] = [a for a in actions[ACTION_MERGE]
                                  if a[0] in mfiles]
 
-    progress.update(None)
+    progress.complete()
     return updateresult(updated, merged, removed, unresolved)
 
 def recordupdates(repo, actions, branchmerge):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2195,7 +2195,7 @@
             except error.LookupError:
                 warnings.append(_("skipping missing subrepository: %s\n")
                                % join(subpath))
-    progress.update(None)
+    progress.complete()
 
     # warn about failure to delete explicit files/dirs
     deleteddirs = util.dirs(deleted)
@@ -2224,7 +2224,7 @@
                         % m.rel(f))
         # missing files will generate a warning elsewhere
         ret = 1
-    progress.update(None)
+    progress.complete()
 
     if force:
         list = modified + deleted + clean + added
@@ -2239,7 +2239,7 @@
                 warnings.append(_('not removing %s: file still exists\n')
                                 % m.rel(f))
             ret = 1
-        progress.update(None)
+        progress.complete()
     else:
         list = deleted + clean
         progress = ui.makeprogress(_('skipping'),
@@ -2255,16 +2255,16 @@
             warnings.append(_("not removing %s: file has been marked for add"
                       " (use 'hg forget' to undo add)\n") % m.rel(f))
             ret = 1
-        progress.update(None)
+        progress.complete()
 
     list = sorted(list)
     progress = ui.makeprogress(_('deleting'), total=len(list),
                                unit=_('files'))
     for f in list:
         if ui.verbose or not m.exact(f):
             progress.increment()
             ui.status(_('removing %s\n') % m.rel(f))
-    progress.update(None)
+    progress.complete()
 
     if not dryrun:
         with repo.wlock():
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -246,7 +246,7 @@
         self.manifestheader()
         deltas = self.deltaiter()
         repo.manifestlog._revlog.addgroup(deltas, revmap, trp)
-        prog.update(None)
+        prog.complete()
         self.callback = None
 
     def apply(self, repo, tr, srctype, url, targetphase=phases.draft,
@@ -309,7 +309,7 @@
                                   config='warn-empty-changegroup')
             clend = len(cl)
             changesets = clend - clstart
-            progress.update(None)
+            progress.complete()
             self.callback = None
 
             # pull off the manifest group



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


More information about the Mercurial-devel mailing list