changeset 7342:1dcd2cc6878b

protocol: avoid sending outrageously large between requests
author Matt Mackall <mpm@selenic.com>
date Fri, 07 Nov 2008 15:30:25 -0600
parents 6cb522c5d56a
children e47dab64be8d
files mercurial/httprepo.py
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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))