# HG changeset patch # User Jun Wu # Date 1494539522 25200 # Node ID 8a137ef6e5dae7b607ab1bb94567d7d3b4391880 # Parent 27e67cfea27fde93285882207f55b00b8d939386 verify: always check rawsize Previously, verify only checks "rawsize == len(rawtext)", if "len(fl.read()) != fl.size()". With flag processor, "len(fl.read()) != fl.size()" does not necessarily mean "rawsize == len(rawtext)". So we may miss a useful check. This patch removes the "if len(fl.read()) != fl.size()" condition so the rawsize check is always performed. With the condition removed, "fl.read(n)" looks unnecessary so a comment was added to explain the side effect is wanted. diff -r 27e67cfea27f -r 8a137ef6e5da mercurial/verify.py --- a/mercurial/verify.py Thu May 11 22:38:15 2017 -0700 +++ b/mercurial/verify.py Thu May 11 14:52:02 2017 -0700 @@ -427,13 +427,14 @@ # 2. hash check: depending on flag processor, we may need to # use either "text" (external), or "rawtext" (in revlog). try: - l = len(fl.read(n)) + fl.read(n) # side effect: read content and do checkhash rp = fl.renamed(n) - if l != 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) + # the "L1 == L2" check + l1 = fl.rawsize(i) + l2 = len(fl.revision(n, raw=True)) + if l1 != l2: + self.err(lr, _("unpacked size is %s, %s expected") % + (l2, l1), f) except error.CensoredNodeError: # experimental config: censor.policy if ui.config("censor", "policy", "abort") == "abort":