revlog: use chunk cache to avoid rereading when splitting inline files
authorMatt Mackall <mpm@selenic.com>
Thu, 07 May 2009 19:39:45 -0500
changeset 8317 5cdf4067857a
parent 8316 d593922cf480
child 8318 6b8513f8274a
revlog: use chunk cache to avoid rereading when splitting inline files
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
@@ -1019,8 +1019,9 @@
 
         tr.add(self.datafile, dataoff)
 
-        if not fp:
-            fp = self.opener(self.indexfile, 'r')
+        if fp:
+            fp.flush()
+            fp.close()
 
         df = self.opener(self.datafile, 'w')
         try:
@@ -1028,13 +1029,11 @@
             for r in self:
                 start = self.start(r) + (r + 1) * calc
                 length = self.length(r)
-                fp.seek(start)
-                d = fp.read(length)
+                d = self._getchunk(start, length)
                 df.write(d)
         finally:
             df.close()
 
-        fp.close()
         fp = self.opener(self.indexfile, 'w', atomictemp=True)
         self.version &= ~(REVLOGNGINLINEDATA)
         self._inline = False