revlog: move stat inside lazyparser
authorMatt Mackall <mpm@selenic.com>
Wed, 27 May 2009 14:44:51 -0500
changeset 8641 33686ef26f04
parent 8640 8536119f2f94
child 8642 2ed353a413b1
revlog: move stat inside lazyparser
mercurial/revlog.py
--- a/mercurial/revlog.py	Mon May 25 12:48:15 2009 -0500
+++ b/mercurial/revlog.py	Wed May 27 14:44:51 2009 -0500
@@ -119,7 +119,11 @@
     # available. it keeps file handle open, which make it not possible
     # to break hardlinks on local cloned repos.
 
-    def __init__(self, dataf, size):
+    def __init__(self, dataf):
+        try:
+            size = util.fstat(dataf).st_size
+        except AttributeError:
+            size = 0
         self.dataf = dataf
         self.s = struct.calcsize(indexformatng)
         self.datasize = size
@@ -362,15 +366,10 @@
         self.size = struct.calcsize(indexformatng)
 
     def parseindex(self, fp, data, inline):
-        size = len(data)
-        if size == _prereadsize:
+        if len(data) == _prereadsize:
             if util.openhardlinks() and not inline:
-                try:
-                    size = util.fstat(fp).st_size
-                except AttributeError:
-                    size = 0
                 # big index, let's parse it on demand
-                parser = lazyparser(fp, size)
+                parser = lazyparser(fp)
                 index = lazyindex(parser)
                 nodemap = lazymap(parser)
                 e = list(index[0])