diff mercurial/revlog.py @ 31856:0ab7f469d386

revlog: make "size" diverge from "rawsize" Previously, revlog.size equals to revlog.rawsize. However, the flag processor framework could make a difference - "size" could mean the length of len(revision(raw=False)), while "rawsize" means len(revision(raw=True)). This patch makes it so. This corrects "hg status" output when flag processor is involved. The call stack looks like: basectx.status -> workingctx._buildstatus -> workingctx._dirstatestatus -> workingctx._checklookup -> filectx.cmp -> filelog.cmp -> filelog.size -> revlog.size
author Jun Wu <quark@fb.com>
date Sun, 09 Apr 2017 12:53:31 -0700
parents 726f24123f02
children e9d325cfe071 1395f843ece4
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Apr 07 10:56:53 2017 -0700
+++ b/mercurial/revlog.py	Sun Apr 09 12:53:31 2017 -0700
@@ -446,7 +446,16 @@
 
         t = self.revision(rev, raw=True)
         return len(t)
-    size = rawsize
+
+    def size(self, rev):
+        """length of non-raw text (processed by a "read" flag processor)"""
+        # fast path: if no "read" flag processor could change the content,
+        # size is rawsize. note: ELLIPSIS is known to not change the content.
+        flags = self.flags(rev)
+        if flags & (REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0:
+            return self.rawsize(rev)
+
+        return len(self.revision(rev, raw=False))
 
     def chainbase(self, rev):
         base = self._chainbasecache.get(rev)