diff hgext/largefiles/lfcommands.py @ 17127:9e1616307c4c

largefiles: batch statlfile requests when pushing a largefiles repo (issue3386) This implements a part of issue 3386. It batches the request for the status of all largefiles in the revisions that are about to be pushed into a single request, instead of doing N separate requests. In a real world test case, this change was verified to save 1,116 round-trips to the server. It only requires a client-side change; it is backwards-compatible with an older version of the server.
author Na'Tosha Bard <natosha@unity3d.com>
date Sun, 24 Jun 2012 20:36:22 +0200
parents 3e24ce3de5f1
children 88ff28bcd980
line wrap: on
line diff
--- a/hgext/largefiles/lfcommands.py	Wed Jul 04 02:21:04 2012 +0200
+++ b/hgext/largefiles/lfcommands.py	Sun Jun 24 20:36:22 2012 +0200
@@ -340,7 +340,11 @@
     store = basestore._openstore(rsrc, rdst, put=True)
 
     at = 0
-    files = filter(lambda h: not store.exists(h), files)
+    ui.debug("sending statlfile command for %d largefiles\n" % len(files))
+    retval = store.exists(files)
+    files = filter(lambda h: not retval[h], files)
+    ui.debug("%d largefiles need to be uploaded\n" % len(files))
+
     for hash in files:
         ui.progress(_('uploading largefiles'), at, unit='largefile',
                     total=len(files))