Mercurial > hg
changeset 2289:854954fd410a
Fix revlog.parseindex
parseindex could fail if read returns too little data in the right
moment (e.g. when there's still leftover data from the previous
iteration and read returns less than "s" bytes).
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sun, 14 May 2006 18:22:12 -0300 |
parents | 09ed44225571 |
children | 6563438219e3 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 5 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Sun May 14 18:24:32 2006 +0200 +++ b/mercurial/revlog.py Sun May 14 18:22:12 2006 -0300 @@ -405,19 +405,17 @@ if n == 0 and self.inlinedata(): # cache the first chunk self.chunkcache = (0, data) + if leftover: + data = leftover + data + leftover = None off = 0 l = len(data) while off < l: if l - off < s: leftover = data[off:] break - if leftover: - cur = leftover + data[off:off + s - len(leftover)] - off += s - len(leftover) - leftover = None - else: - cur = data[off:off + s] - off += s + cur = data[off:off + s] + off += s e = struct.unpack(self.indexformat, cur) self.index.append(e) self.nodemap[e[-1]] = n