Patchwork [5,of,7,RFC,v2] verify: report censored node integrity failures as warnings if config allows

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 15, 2014, 12:01 p.m.
Message ID <cb2d62a677e6df6b50df.1410782486@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5824/
State Accepted
Headers show

Comments

michaeljedgar@gmail.com - Sept. 15, 2014, 12:01 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1410741009 14400
#      Sun Sep 14 20:30:09 2014 -0400
# Node ID cb2d62a677e6df6b50df1699e7eea212a82af98d
# Parent  264440edaa441525b98e776df76672304b7eb120
verify: report censored node integrity failures as warnings if config allows

Verify is one of the most significant code paths which must handle censored
revlog nodes, and must do so safely. This change uses the censor module for
configurable verification.

Patch

diff -r 264440edaa44 -r cb2d62a677e6 mercurial/verify.py
--- a/mercurial/verify.py	Sun Sep 14 16:41:16 2014 -0400
+++ b/mercurial/verify.py	Sun Sep 14 20:30:09 2014 -0400
@@ -260,13 +260,19 @@ 
                     del filenodes[f][n]
 
             # verify contents
+            fc = repo.filectx(f, changeid=lr, fileid=n)
             try:
-                l = len(fl.read(n))
-                rp = fl.renamed(n)
-                if l != fl.size(i):
-                    if len(fl.revision(n)) != fl.size(i):
+                l = len(fc.data())
+                rp = fc.renamed()
+                if l != fc.size():
+                    if len(fl.revision(n)) != fc.size():
                         err(lr, _("unpacked size is %s, %s expected") %
-                            (l, fl.size(i)), f)
+                            (l, fc.size()), f)
+            except revlog.CensoredNodeError:
+                if fc.censorallowed():
+                    warn(_("warning: node %s censored from %s") % (short(n), f))
+                else:
+                    err(lr, _("node %s censored from %s") % (short(n), f))
             except Exception, inst:
                 exc(lr, _("unpacking %s") % short(n), inst, f)