changeset 8558:5726bb290bfe

revlog: fix reading of larger revlog indices on Windows
author Matt Mackall <mpm@selenic.com>
date Sat, 23 May 2009 11:53:23 -0500
parents 67f76a4463ef
children 4429751f5da7
files mercurial/revlog.py
diffstat 1 files changed, 14 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri May 08 12:19:57 2009 +0900
+++ b/mercurial/revlog.py	Sat May 23 11:53:23 2009 -0500
@@ -322,7 +322,7 @@
         index = []
         nodemap =  {nullid: nullrev}
         n = off = 0
-        if len(data) < _prereadsize:
+        if len(data) == _prereadsize:
             data += fp.read() # read the rest
         l = len(data)
         while off + s <= l:
@@ -362,23 +362,19 @@
         self.size = struct.calcsize(indexformatng)
 
     def parseindex(self, fp, data, inline):
-        try:
-            size = len(data)
-            if size == _prereadsize:
-                size = util.fstat(fp).st_size
-        except AttributeError:
-            size = 0
-
-        if util.openhardlinks() and not inline and size > _prereadsize:
-            # big index, let's parse it on demand
-            parser = lazyparser(fp, size)
-            index = lazyindex(parser)
-            nodemap = lazymap(parser)
-            e = list(index[0])
-            type = gettype(e[0])
-            e[0] = offset_type(0, type)
-            index[0] = e
-            return index, nodemap, None
+        if len(data) == _prereadsize:
+            if util.openhardlinks() and not inline:
+                # big index, let's parse it on demand
+                parser = lazyparser(fp, size)
+                index = lazyindex(parser)
+                nodemap = lazymap(parser)
+                e = list(index[0])
+                type = gettype(e[0])
+                e[0] = offset_type(0, type)
+                index[0] = e
+                return index, nodemap, None
+            else:
+                data += fp.read()
 
         # call the C implementation to parse the index data
         index, nodemap, cache = parsers.parse_index(data, inline)