Patchwork D5386: remotefilelog: rely on progress helper for keeping track of position

login
register
mail settings
Submitter phabricator
Date Dec. 6, 2018, 11:41 a.m.
Message ID <deba701a7f505f48a160a7959f7ecaf8@localhost.localdomain>
Download mbox | patch
Permalink /patch/37016/
State Not Applicable
Headers show

Comments

phabricator - Dec. 6, 2018, 11:41 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG74e3df766052: remotefilelog: rely on progress helper for keeping track of position (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5386?vs=12725&id=12747

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

AFFECTED FILES
  hgext/remotefilelog/fileserverclient.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/remotefilelog/fileserverclient.py b/hgext/remotefilelog/fileserverclient.py
--- a/hgext/remotefilelog/fileserverclient.py
+++ b/hgext/remotefilelog/fileserverclient.py
@@ -334,7 +334,6 @@ 
         progress.update(0)
 
         missed = []
-        count = 0
         while True:
             missingid = cache.receiveline()
             if not missingid:
@@ -350,28 +349,23 @@ 
             if missingid.startswith("_hits_"):
                 # receive progress reports
                 parts = missingid.split("_")
-                count += int(parts[2])
-                progress.update(count)
+                progress.increment(int(parts[2]))
                 continue
 
             missed.append(missingid)
 
         global fetchmisses
         fetchmisses += len(missed)
 
         fromcache = total - len(missed)
-        count = [fromcache]
         progress.update(fromcache, total=total)
         self.ui.log("remotefilelog", "remote cache hit rate is %r of %r\n",
                     fromcache, total, hit=fromcache, total=total)
 
         oldumask = os.umask(0o002)
         try:
             # receive cache misses from master
             if missed:
-                def progresstick():
-                    count[0] += 1
-                    progress.update(count[0])
                 # When verbose is true, sshpeer prints 'running ssh...'
                 # to stdout, which can interfere with some command
                 # outputs
@@ -393,30 +387,30 @@ 
                                 _getfiles = _getfiles_threaded
                             else:
                                 _getfiles = _getfiles_optimistic
-                            _getfiles(remote, self.receivemissing, progresstick,
-                                      missed, idmap, step)
+                            _getfiles(remote, self.receivemissing,
+                                      progress.increment, missed, idmap, step)
                         elif remote.capable("x_rfl_getfile"):
                             if remote.capable('batch'):
                                 batchdefault = 100
                             else:
                                 batchdefault = 10
                             batchsize = self.ui.configint(
                                 'remotefilelog', 'batchsize', batchdefault)
                             _getfilesbatch(
-                                remote, self.receivemissing, progresstick,
+                                remote, self.receivemissing, progress.increment,
                                 missed, idmap, batchsize)
                         else:
                             raise error.Abort("configured remotefilelog server"
                                              " does not support remotefilelog")
 
                     self.ui.log("remotefilefetchlog",
                                 "Success\n",
-                                fetched_files = count[0] - fromcache,
+                                fetched_files = progress.pos - fromcache,
                                 total_to_fetch = total - fromcache)
                 except Exception:
                     self.ui.log("remotefilefetchlog",
                                 "Fail\n",
-                                fetched_files = count[0] - fromcache,
+                                fetched_files = progress.pos - fromcache,
                                 total_to_fetch = total - fromcache)
                     raise
                 finally: