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

Mike Edgar michaeljedgar at gmail.com
Mon Sep 15 07:01:26 CDT 2014


# HG changeset patch
# User Mike Edgar <adgar at 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.

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)
 


More information about the Mercurial-devel mailing list