Mercurial > hg
changeset 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 | a418c5837bc0 |
children | 08fbc97d1364 |
files | mercurial/revlog.py tests/test-flagprocessor.t |
diffstat | 2 files changed, 10 insertions(+), 2 deletions(-) [+] |
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)