# HG changeset patch # User Benoit Boissinot # Date 1280056257 -7200 # Node ID 1b3b843e11002e95e8675f8028e478122e076def # Parent c47cb3193c534f6899e32e26bf9510da2ef0b7d5 chunkbuffer: split big strings directly in chunkbuffer diff -r c47cb3193c53 -r 1b3b843e1100 mercurial/revlog.py --- a/mercurial/revlog.py Sun Jul 25 10:05:38 2010 +0900 +++ b/mercurial/revlog.py Sun Jul 25 13:10:57 2010 +0200 @@ -1193,14 +1193,7 @@ d = self.revdiff(a, b) yield changegroup.chunkheader(len(meta) + len(d)) yield meta - if len(d) > 2**20: - pos = 0 - while pos < len(d): - pos2 = pos + 2 ** 18 - yield d[pos:pos2] - pos = pos2 - else: - yield d + yield d yield changegroup.closechunk() diff -r c47cb3193c53 -r 1b3b843e1100 mercurial/util.py --- a/mercurial/util.py Sun Jul 25 10:05:38 2010 +0900 +++ b/mercurial/util.py Sun Jul 25 13:10:57 2010 +0200 @@ -914,7 +914,17 @@ def __init__(self, in_iter): """in_iter is the iterator that's iterating over the input chunks. targetsize is how big a buffer to try to maintain.""" - self.iter = iter(in_iter) + def splitbig(chunks): + for chunk in chunks: + if len(chunk) > 2**20: + pos = 0 + while pos < len(chunk): + end = pos + 2 ** 18 + yield chunk[pos:end] + pos = end + else: + yield chunk + self.iter = splitbig(in_iter) self.buf = '' def read(self, l):