# HG changeset patch # User Matt Mackall # Date 1226093425 21600 # Node ID 1dcd2cc6878bd5afeb91c397f59f335e57a9ef69 # Parent 6cb522c5d56a80120403474c88d2c2e250cbb8ae protocol: avoid sending outrageously large between requests diff -r 6cb522c5d56a -r 1dcd2cc6878b 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))