Patchwork [1,of,7,RFC,v2] error: add CensoredNodeError, will be thrown when content deliberately erased

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 15, 2014, 12:01 p.m.
Message ID <0dc057ad6ad1e9ab481d.1410782482@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5822/
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 1409774343 14400
#      Wed Sep 03 15:59:03 2014 -0400
# Node ID 0dc057ad6ad1e9ab481d461c426e72965d951445
# Parent  c1cf6ab049096e375922a977017d50939b8d4c5d
error: add CensoredNodeError, will be thrown when content deliberately erased

This change introduces the error plus a corresponding catch in dispatch, to
provide localized error messages.

The verb "censor" is used in this commit and all following to refer to erasing
the content of a revlog revision (filelog, for now) without recalculating node
IDs, leaving that revision invalid. Further work must be done to safely share
such revision data with compliant clients.

I find the analogy to censorship straightforward; for less politically
charged options, consider "erase", "excise", "expunge", or "blackhole".

Patch

diff -r c1cf6ab04909 -r 0dc057ad6ad1 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Sun Aug 31 23:50:53 2014 +0200
+++ b/mercurial/dispatch.py	Wed Sep 03 15:59:03 2014 -0400
@@ -193,6 +193,8 @@ 
             ui.warn(_(" empty string\n"))
         else:
             ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
+    except error.CensoredNodeError, inst:
+        ui.warn(_("abort: file censored %s!\n") % inst)
     except error.RevlogError, inst:
         ui.warn(_("abort: %s!\n") % inst)
     except error.SignalInterrupt:
diff -r c1cf6ab04909 -r 0dc057ad6ad1 mercurial/error.py
--- a/mercurial/error.py	Sun Aug 31 23:50:53 2014 +0200
+++ b/mercurial/error.py	Wed Sep 03 15:59:03 2014 -0400
@@ -117,3 +117,9 @@ 
     """error raised when code tries to alter a part being generated"""
     pass
 
+class CensoredNodeError(RevlogError):
+    """error raised when content verification fails on a censored node"""
+
+    def __init__(self, filename, node):
+        from node import short
+        RevlogError.__init__(self, '%s:%s' % (filename, short(node)))