# HG changeset patch # User Gregory Szorc # Date 1444088087 25200 # Node ID 46143f31290e489181a1a88a1ef42ccfad17a489 # Parent a3f7e5461dbd7cfd7cbbe960aa23a622afe2afae util.chunkbuffer: refactor chunk handling logic This will make the next patch easier to read. It provides no benefit on its own. diff -r a3f7e5461dbd -r 46143f31290e mercurial/util.py --- a/mercurial/util.py Mon Oct 05 16:28:12 2015 -0700 +++ b/mercurial/util.py Mon Oct 05 16:34:47 2015 -0700 @@ -1310,13 +1310,20 @@ if not queue: break - chunk = queue.popleft() - left -= len(chunk) - if left < 0: + chunk = queue[0] + chunkl = len(chunk) + + # Use full chunk. + if left >= chunkl: + left -= chunkl + queue.popleft() + buf.append(chunk) + # Partial chunk needed. + else: + left -= chunkl + queue.popleft() queue.appendleft(chunk[left:]) buf.append(chunk[:left]) - else: - buf.append(chunk) return ''.join(buf)