revlog: use index to find index size
authorMatt Mackall <mpm@selenic.com>
Thu, 07 May 2009 19:39:45 -0500
changeset 8315 c8493310ad9b
parent 8314 57a41c08feab
child 8316 d593922cf480
revlog: use index to find index size
mercurial/revlog.py
--- a/mercurial/revlog.py	Thu May 07 19:39:45 2009 -0500
+++ b/mercurial/revlog.py	Thu May 07 19:39:45 2009 -0500
@@ -998,14 +998,9 @@
         return text
 
     def checkinlinesize(self, tr, fp=None):
-        if not self._inline:
+        if not self._inline or (self.start(-2) + self.length(-2)) < 131072:
             return
-        if not fp:
-            fp = self.opener(self.indexfile, 'r')
-            fp.seek(0, 2)
-        size = fp.tell()
-        if size < 131072:
-            return
+
         trinfo = tr.find(self.indexfile)
         if trinfo == None:
             raise RevlogError(_("%s not found in the transaction")
@@ -1015,6 +1010,10 @@
         dataoff = self.start(trindex)
 
         tr.add(self.datafile, dataoff)
+
+        if not fp:
+            fp = self.opener(self.indexfile, 'r')
+
         df = self.opener(self.datafile, 'w')
         try:
             calc = self._io.size