Patchwork [2,of,2] verify: fix length check

login
register
mail settings
Submitter Jun Wu
Date March 29, 2017, 9:52 p.m.
Message ID <ab735d6798fb133efdc2.1490824320@x1c>
Download mbox | patch
Permalink /patch/19832/
State Changes Requested
Headers show

Comments

Jun Wu - March 29, 2017, 9:52 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1490824154 25200
#      Wed Mar 29 14:49:14 2017 -0700
# Node ID ab735d6798fb133efdc2be8a441b51e7ba4d547b
# Parent  1f7890370b5437466534cbd0a313d21671dade03
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r ab735d6798fb
verify: fix length check

According to the document added above, we should check L1 == L2, and the
only way to get L1 in all cases is to call "rawsize()", and the only way to
get L2 is to call "revision(raw=True)". Therefore the fix.

Meanwhile there are still a lot of things about flagprocessor broken in
revlog.py. Tests will be added after revlog.py gets fixed.
Ryan McElroy - March 30, 2017, 8:57 a.m.
On 3/29/17 10:52 PM, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark@fb.com>
> # Date 1490824154 25200
> #      Wed Mar 29 14:49:14 2017 -0700
> # Node ID ab735d6798fb133efdc2be8a441b51e7ba4d547b
> # Parent  1f7890370b5437466534cbd0a313d21671dade03
> verify: fix length check
>
> According to the document added above, we should check L1 == L2, and the
> only way to get L1 in all cases is to call "rawsize()", and the only way to
> get L2 is to call "revision(raw=True)". Therefore the fix.
>
> Meanwhile there are still a lot of things about flagprocessor broken in
> revlog.py. Tests will be added after revlog.py gets fixed.
>
> diff --git a/mercurial/verify.py b/mercurial/verify.py
> --- a/mercurial/verify.py
> +++ b/mercurial/verify.py
> @@ -425,5 +425,6 @@ class verifier(object):
>                       rp = fl.renamed(n)
>                       if l != fl.size(i):
> -                        if len(fl.revision(n)) != fl.size(i):
> +                        # the "L1 == L2" check
> +                        if len(fl.revision(n, raw=True)) != fl.rawsize(i):
>                               self.err(lr, _("unpacked size is %s, %s expected") %
>                                        (l, fl.size(i)), f)
>

This fix looks good and important to me.

I'd suggest sending a v2 with the names in the table documented more 
clearly (from patch 1), as well as the typo you mentioned in your reply.

I'll mark as "changes requested" in patchwork.

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -425,5 +425,6 @@  class verifier(object):
                     rp = fl.renamed(n)
                     if l != fl.size(i):
-                        if len(fl.revision(n)) != fl.size(i):
+                        # the "L1 == L2" check
+                        if len(fl.revision(n, raw=True)) != fl.rawsize(i):
                             self.err(lr, _("unpacked size is %s, %s expected") %
                                      (l, fl.size(i)), f)