# HG changeset patch # User Matt Mackall # Date 2008-11-07 21:30:25 # Node ID 1dcd2cc6878bd5afeb91c397f59f335e57a9ef69 # Parent 6cb522c5d56a80120403474c88d2c2e250cbb8ae protocol: avoid sending outrageously large between requests diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -148,13 +148,16 @@ class httprepository(repo.repository): 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))