diff mercurial/revlog.py @ 2084:d66278012853

Fix transaction handling during interleaved file split.
author Chris Mason <mason@suse.com>
date Mon, 17 Apr 2006 13:19:58 -0400
parents 856f0ba200bc
children cb99c711c59f
line wrap: on
line diff
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -826,7 +826,15 @@ class revlog(object):
         size = fp.tell()
         if size < 131072:
             return
-        tr.add(self.datafile, 0)
+        trinfo = tr.find(self.indexfile)
+        if trinfo == None:
+            raise RevlogError(_("%s not found in the transaction"  %
+                              self.indexfile))
+
+        trindex = trinfo[2]
+        dataoff = self.start(trindex)
+
+        tr.add(self.datafile, dataoff)
         df = self.opener(self.datafile, 'w')
         calc = struct.calcsize(self.indexformat)
         for r in xrange(self.count()):
@@ -854,6 +862,8 @@ class revlog(object):
         # if we don't call rename, the temp file will never replace the
         # real index
         fp.rename()
+
+        tr.replace(self.indexfile, trindex * calc)
         self.chunkcache = None
 
     def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):
@@ -922,7 +932,7 @@ class revlog(object):
         else:
             f = self.opener(self.indexfile, "a+")
             f.seek(0, 2)
-            transaction.add(self.indexfile, f.tell())
+            transaction.add(self.indexfile, f.tell(), self.count() - 1)
 
         if len(self.index) == 1 and self.version != 0:
             l = struct.pack(versionformat, self.version)
@@ -1071,7 +1081,7 @@ class revlog(object):
 
         ifh = self.opener(self.indexfile, "a+")
         ifh.seek(0, 2)
-        transaction.add(self.indexfile, ifh.tell())
+        transaction.add(self.indexfile, ifh.tell(), self.count())
         if self.inlinedata():
             dfh = None
         else: