protocol: avoid sending outrageously large between requests
authorMatt Mackall <mpm@selenic.com>
Fri, 07 Nov 2008 15:30:25 -0600
changeset 7342 1dcd2cc6878b
parent 7341 6cb522c5d56a
child 7343 e47dab64be8d
protocol: avoid sending outrageously large between requests
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Thu Nov 06 13:15:35 2008 -0600
+++ b/mercurial/httprepo.py	Fri Nov 07 15:30:25 2008 -0600
@@ -148,13 +148,16 @@
             raise util.UnexpectedOutput(_("unexpected response:"), d)
 
     def between(self, pairs):
-        n = " ".join(["-".join(map(hex, p)) for p in pairs])
-        d = self.do_read("between", pairs=n)
-        try:
-            p = [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ]
-            return p
-        except:
-            raise util.UnexpectedOutput(_("unexpected response:"), d)
+        batch = 8 # avoid giant requests
+        r = []
+        for i in xrange(0, len(pairs), batch):
+            n = " ".join(["-".join(map(hex, p)) for p in pairs[i:i + batch]])
+            d = self.do_read("between", pairs=n)
+            try:
+                r += [ l and map(bin, l.split(" ")) or [] for l in d.splitlines() ]
+            except:
+                raise util.UnexpectedOutput(_("unexpected response:"), d)
+        return r
 
     def changegroup(self, nodes, kind):
         n = " ".join(map(hex, nodes))