diff mercurial/revlog.py @ 2075:343aeefb553b

Make the appendfile class inline-data index friendly The appendfile class needs a few changes to make it work with interleaved index files. It needs to support the tell() method, opening in a+ mode, and it needs to delay the checkinlinesize call until after the append file is written. Given that open(file, "a+") doesn't always seek to the end of the file, this adds seek operations to appendfile that understand whence args
author mason@suse.com
date Tue, 04 Apr 2006 16:38:43 -0400
parents 1e6745f78989
children d007df6daf8e
line wrap: on
line diff
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -675,9 +675,11 @@ class revlog(object):
         self.cache = (node, rev, text)
         return text
 
-    def checkinlinesize(self, fp, tr):
+    def checkinlinesize(self, tr, fp=None):
         if not self.inlinedata():
             return
+        if not fp:
+            fp = self.opener(self.indexfile, 'r')
         size = fp.tell()
         if size < 131072:
             return
@@ -786,7 +788,7 @@ class revlog(object):
         if self.inlinedata():
             f.write(data[0])
             f.write(data[1])
-            self.checkinlinesize(f, transaction)
+            self.checkinlinesize(transaction, f)
 
         self.cache = (node, n, text)
         return node
@@ -966,7 +968,7 @@ class revlog(object):
                 if self.inlinedata():
                     ifh.write(struct.pack(self.indexformat, *e))
                     ifh.write(cdelta)
-                    self.checkinlinesize(ifh, transaction)
+                    self.checkinlinesize(transaction, ifh)
                     if not self.inlinedata():
                         dfh = self.opener(self.datafile, "a")
                         ifh = self.opener(self.indexfile, "a")