[PATCH 2 of 2 V2] revlog: make "size" diverge from "rawsize"

Ryan McElroy rm at fb.com
Mon Apr 10 05:04:19 EDT 2017


On 4/9/17 9:14 PM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1491767611 25200
> #      Sun Apr 09 12:53:31 2017 -0700
> # Node ID 02a64e62a50699e224381821202c984c71460406
> # Parent  01c8cf2cb588eea28df5f09853c702d380b631a9
> revlog: make "size" diverge from "rawsize"

This series looks good to me. Marked as pre-reviewed in patchwork.

>
> 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
>
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -447,5 +447,14 @@ class revlog(object):
>           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):
> diff --git a/tests/test-flagprocessor.t b/tests/test-flagprocessor.t
> --- a/tests/test-flagprocessor.t
> +++ b/tests/test-flagprocessor.t
> @@ -245,4 +245,3 @@
>   
>     $ hg status
> -  M base64
>     $ hg diff
>



More information about the Mercurial-devel mailing list