merge: use file size stored in revlog index
authorMatt Mackall <mpm@selenic.com>
Tue, 15 Aug 2006 22:46:35 -0500
changeset 2898 db397c38005d
parent 2897 dd032b0f02ac
child 2899 8743188f4d2e
merge: use file size stored in revlog index Add size method to filelog to handle nodes with renames
mercurial/filelog.py
mercurial/merge.py
--- a/mercurial/filelog.py	Tue Aug 15 18:30:21 2006 -0500
+++ b/mercurial/filelog.py	Tue Aug 15 22:46:35 2006 -0500
@@ -65,6 +65,16 @@
             return (m["copy"], bin(m["copyrev"]))
         return False
 
+    def size(self, rev):
+        """return the size of a given revision"""
+
+        # for revisions with renames, we have to go the slow way
+        node = self.node(rev)
+        if self.renamed(node):
+            return len(self.read(node))
+
+        return revlog.size(self, rev)
+
     def cmp(self, node, text):
         """compare text with a given file revision"""
 
--- a/mercurial/merge.py	Tue Aug 15 18:30:21 2006 -0500
+++ b/mercurial/merge.py	Tue Aug 15 22:46:35 2006 -0500
@@ -282,7 +282,8 @@
                 # of that file some time in the past. Thus our
                 # merge will appear as a normal local file
                 # modification.
-                f_len = len(repo.file(f).read(other))
+                fl = repo.file(f)
+                f_len = fl.size(fl.rev(other))
                 repo.dirstate.update([f], 'n', st_size=f_len, st_mtime=-1)
 
     remove.sort()