hgext/remotefilelog/fileserverclient.py
changeset 40869 74e3df766052
parent 40868 fcee112fb7c4
child 41768 aaad36b88298
equal deleted inserted replaced
40868:fcee112fb7c4 40869:74e3df766052
   332 
   332 
   333         progress = self.ui.makeprogress(_('downloading'), total=total)
   333         progress = self.ui.makeprogress(_('downloading'), total=total)
   334         progress.update(0)
   334         progress.update(0)
   335 
   335 
   336         missed = []
   336         missed = []
   337         count = 0
       
   338         while True:
   337         while True:
   339             missingid = cache.receiveline()
   338             missingid = cache.receiveline()
   340             if not missingid:
   339             if not missingid:
   341                 missedset = set(missed)
   340                 missedset = set(missed)
   342                 for missingid in idmap:
   341                 for missingid in idmap:
   348             if missingid == "0":
   347             if missingid == "0":
   349                 break
   348                 break
   350             if missingid.startswith("_hits_"):
   349             if missingid.startswith("_hits_"):
   351                 # receive progress reports
   350                 # receive progress reports
   352                 parts = missingid.split("_")
   351                 parts = missingid.split("_")
   353                 count += int(parts[2])
   352                 progress.increment(int(parts[2]))
   354                 progress.update(count)
       
   355                 continue
   353                 continue
   356 
   354 
   357             missed.append(missingid)
   355             missed.append(missingid)
   358 
   356 
   359         global fetchmisses
   357         global fetchmisses
   360         fetchmisses += len(missed)
   358         fetchmisses += len(missed)
   361 
   359 
   362         fromcache = total - len(missed)
   360         fromcache = total - len(missed)
   363         count = [fromcache]
       
   364         progress.update(fromcache, total=total)
   361         progress.update(fromcache, total=total)
   365         self.ui.log("remotefilelog", "remote cache hit rate is %r of %r\n",
   362         self.ui.log("remotefilelog", "remote cache hit rate is %r of %r\n",
   366                     fromcache, total, hit=fromcache, total=total)
   363                     fromcache, total, hit=fromcache, total=total)
   367 
   364 
   368         oldumask = os.umask(0o002)
   365         oldumask = os.umask(0o002)
   369         try:
   366         try:
   370             # receive cache misses from master
   367             # receive cache misses from master
   371             if missed:
   368             if missed:
   372                 def progresstick():
       
   373                     count[0] += 1
       
   374                     progress.update(count[0])
       
   375                 # When verbose is true, sshpeer prints 'running ssh...'
   369                 # When verbose is true, sshpeer prints 'running ssh...'
   376                 # to stdout, which can interfere with some command
   370                 # to stdout, which can interfere with some command
   377                 # outputs
   371                 # outputs
   378                 verbose = self.ui.verbose
   372                 verbose = self.ui.verbose
   379                 self.ui.verbose = False
   373                 self.ui.verbose = False
   391                                                           'getfilestype')
   385                                                           'getfilestype')
   392                             if getfilestype == 'threaded':
   386                             if getfilestype == 'threaded':
   393                                 _getfiles = _getfiles_threaded
   387                                 _getfiles = _getfiles_threaded
   394                             else:
   388                             else:
   395                                 _getfiles = _getfiles_optimistic
   389                                 _getfiles = _getfiles_optimistic
   396                             _getfiles(remote, self.receivemissing, progresstick,
   390                             _getfiles(remote, self.receivemissing,
   397                                       missed, idmap, step)
   391                                       progress.increment, missed, idmap, step)
   398                         elif remote.capable("x_rfl_getfile"):
   392                         elif remote.capable("x_rfl_getfile"):
   399                             if remote.capable('batch'):
   393                             if remote.capable('batch'):
   400                                 batchdefault = 100
   394                                 batchdefault = 100
   401                             else:
   395                             else:
   402                                 batchdefault = 10
   396                                 batchdefault = 10
   403                             batchsize = self.ui.configint(
   397                             batchsize = self.ui.configint(
   404                                 'remotefilelog', 'batchsize', batchdefault)
   398                                 'remotefilelog', 'batchsize', batchdefault)
   405                             _getfilesbatch(
   399                             _getfilesbatch(
   406                                 remote, self.receivemissing, progresstick,
   400                                 remote, self.receivemissing, progress.increment,
   407                                 missed, idmap, batchsize)
   401                                 missed, idmap, batchsize)
   408                         else:
   402                         else:
   409                             raise error.Abort("configured remotefilelog server"
   403                             raise error.Abort("configured remotefilelog server"
   410                                              " does not support remotefilelog")
   404                                              " does not support remotefilelog")
   411 
   405 
   412                     self.ui.log("remotefilefetchlog",
   406                     self.ui.log("remotefilefetchlog",
   413                                 "Success\n",
   407                                 "Success\n",
   414                                 fetched_files = count[0] - fromcache,
   408                                 fetched_files = progress.pos - fromcache,
   415                                 total_to_fetch = total - fromcache)
   409                                 total_to_fetch = total - fromcache)
   416                 except Exception:
   410                 except Exception:
   417                     self.ui.log("remotefilefetchlog",
   411                     self.ui.log("remotefilefetchlog",
   418                                 "Fail\n",
   412                                 "Fail\n",
   419                                 fetched_files = count[0] - fromcache,
   413                                 fetched_files = progress.pos - fromcache,
   420                                 total_to_fetch = total - fromcache)
   414                                 total_to_fetch = total - fromcache)
   421                     raise
   415                     raise
   422                 finally:
   416                 finally:
   423                     self.ui.verbose = verbose
   417                     self.ui.verbose = verbose
   424                 # send to memcache
   418                 # send to memcache