# HG changeset patch
# User Alexis S. L. Carvalho <alexis@cecm.usp.br>
# Date 2006-09-10 22:15:08
# Node ID baa3873eb38725ab76f8bd2afa3f8486dbdda2ce
# Parent  ad6aecaf4eed0d0a0459f5d8218766ec6e404083

don't let lazyparser read more data than it can handle

This should fix issue368.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -139,6 +139,11 @@ class lazyparser(object):
         if self.all: return
         if data is None:
             self.dataf.seek(blockstart)
+            if blockstart + blocksize > self.datasize:
+                # the revlog may have grown since we've started running,
+                # but we don't have space in self.index for more entries.
+                # limit blocksize so that we don't get too much data.
+                blocksize = self.datasize - blockstart
             data = self.dataf.read(blocksize)
         lend = len(data) / self.s
         i = blockstart / self.s