[PATCH 2 of 2 V2] largefiles: makes verify batching stat calls to remote

liscju piotr.listkiewicz at gmail.com
Tue May 3 17:52:17 EDT 2016


# HG changeset patch
# User liscju <piotr.listkiewicz at gmail.com>
# Date 1462312111 -7200
#      Tue May 03 23:48:31 2016 +0200
# Branch stable
# Node ID ff775d177b1d42ff9cc72add1f8f9a530e02ccd4
# Parent  bf5e258de1e36381a1a66fe4009c137b18c2d70a
largefiles: makes verify batching stat calls to remote

Instead of sending stat calls for each files separately, it sends
one batch call with stat invocations for all files.

diff -r bf5e258de1e3 -r ff775d177b1d hgext/largefiles/remotestore.py
--- a/hgext/largefiles/remotestore.py	Tue May 03 23:31:32 2016 +0200
+++ b/hgext/largefiles/remotestore.py	Tue May 03 23:48:31 2016 +0200
@@ -67,8 +67,11 @@ class remotestore(basestore.basestore):
 
     def _verifyfiles(self, contents, filestocheck):
         failed = False
+        expectedhashes = [expectedhash
+                          for cset, filename, expectedhash in filestocheck]
+        stats = self._stat(expectedhashes)
         for cset, filename, expectedhash in filestocheck:
-            stat = self._stat([expectedhash])[expectedhash]
+            stat = stats[expectedhash]
             if stat:
                 if stat == 1:
                     self.ui.warn(
diff -r bf5e258de1e3 -r ff775d177b1d tests/test-largefiles-wireproto.t
--- a/tests/test-largefiles-wireproto.t	Tue May 03 23:31:32 2016 +0200
+++ b/tests/test-largefiles-wireproto.t	Tue May 03 23:48:31 2016 +0200
@@ -306,4 +306,46 @@ largefiles pulled on update - no server 
 used all HGPORTs, kill all daemons
   $ killdaemons.py
 
+largefiles should batch verify remote calls
+
+  $ hg init batchverifymain
+  $ cd batchverifymain
+  $ echo "aaa" >> a
+  $ hg add --large a
+  $ hg commit -m "a"
+  Invoking status precommit hook
+  A a
+  $ echo "bbb" >> b
+  $ hg add --large b
+  $ hg commit -m "b"
+  Invoking status precommit hook
+  A b
+  $ cd ..
+  $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
+  > -A access.log
+  $ cat hg.pid >> $DAEMON_PIDS
+  $ hg clone http://localhost:$HGPORT batchverifyclone
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+  updating to branch default
+  getting changed largefiles
+  2 largefiles updated, 0 removed
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg -R batchverifyclone verify --large
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  2 files, 2 changesets, 2 total revisions
+  searching 1 changesets for largefiles
+  verified existence of 2 revisions of 2 largefiles
+  $ tail -1 access.log
+  127.0.0.1 - - [*] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a (glob)
+  $ rm access.log
+
+  $ killdaemons.py
+
 #endif


More information about the Mercurial-devel mailing list