changeset 8317:5cdf4067857a

revlog: use chunk cache to avoid rereading when splitting inline files
author Matt Mackall <mpm@selenic.com>
date Thu, 07 May 2009 19:39:45 -0500
parents d593922cf480
children 6b8513f8274a
files mercurial/revlog.py
diffstat 1 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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