largefiles: use command executor for batch operation
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 13 Apr 2018 11:08:46 -0700
changeset 37632 6c55ce51d6c3
parent 37631 2f626233859b
child 37633 33a6eee08db2
largefiles: use command executor for batch operation This is the only other user of iterbatch() in core. Tests changed because the new command executor is smart enough to not send a "batch" command over the wire if only 1 command was requested. There is still coverage for the "batch" command in this test though. Differential Revision: https://phab.mercurial-scm.org/D3270
hgext/largefiles/wirestore.py
tests/test-largefiles-wireproto.t
--- a/hgext/largefiles/wirestore.py	Fri Apr 13 11:02:34 2018 -0700
+++ b/hgext/largefiles/wirestore.py	Fri Apr 13 11:08:46 2018 -0700
@@ -32,8 +32,12 @@
         '''For each hash, return 0 if it is available, other values if not.
         It is usually 2 if the largefile is missing, but might be 1 the server
         has a corrupted copy.'''
-        batch = self.remote.iterbatch()
-        for hash in hashes:
-            batch.statlfile(hash)
-        batch.submit()
-        return dict(zip(hashes, batch.results()))
+
+        with self.remote.commandexecutor() as e:
+            fs = []
+            for hash in hashes:
+                fs.append((hash, e.callcommand('statlfile', {
+                    'sha': hash,
+                })))
+
+            return {hash: f.result() for hash, f in fs}
--- a/tests/test-largefiles-wireproto.t	Fri Apr 13 11:02:34 2018 -0700
+++ b/tests/test-largefiles-wireproto.t	Fri Apr 13 11:08:46 2018 -0700
@@ -312,7 +312,7 @@
   getting changed largefiles
   using http://localhost:$HGPORT2/
   sending capabilities command
-  sending batch command
+  sending statlfile command
   getting largefiles: 0/1 files (0.00%)
   getting f1:02a439e5c31c526465ab1a0ca1f431f76b827b90
   sending getlfile command
@@ -400,7 +400,7 @@
   searching 3 changesets for largefiles
   verified existence of 3 revisions of 3 largefiles
   $ tail -1 access.log
-  $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3Dc8559c3c9cfb42131794b7d8009230403b9b454c x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
+  $LOCALIP - - [$LOGDATE$] "GET /?cmd=statlfile HTTP/1.1" 200 - x-hgarg-1:sha=c8559c3c9cfb42131794b7d8009230403b9b454c x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
 
   $ killdaemons.py