Patchwork [03,of,21,RFC] error: add CensoredNodeError, will be thrown when content deliberately erased

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 11, 2014, 12:26 a.m.
Message ID <c0a3869d01b083463c70.1410395164@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5777/
State Superseded
Commit 244478687edd30038f336814ea03a54e99388946
Headers show

Comments

michaeljedgar@gmail.com - Sept. 11, 2014, 12:26 a.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1409774343 14400
#      Wed Sep 03 15:59:03 2014 -0400
# Node ID c0a3869d01b083463c70bcf5dc7476e6711a50c5
# Parent  4ddf6bdba3e218f3809a1632348167f54498e1e7
error: add CensoredNodeError, will be thrown when content deliberately erased

This merely introduces the error and leaves it unused. The error provides the
censored node in the "node" attribute, as it may be raised in ambiguous
scenarios (eg. delta application).

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", a term
often invoked to indicate permanent data destruction.
Matt Mackall - Sept. 11, 2014, 5:50 p.m.
On Wed, 2014-09-10 at 20:26 -0400, michaeljedgar@gmail.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1409774343 14400
> #      Wed Sep 03 15:59:03 2014 -0400
> # Node ID c0a3869d01b083463c70bcf5dc7476e6711a50c5
> # Parent  4ddf6bdba3e218f3809a1632348167f54498e1e7
> error: add CensoredNodeError, will be thrown when content deliberately erased
> 
> This merely introduces the error and leaves it unused. The error provides the
> censored node in the "node" attribute, as it may be raised in ambiguous
> scenarios (eg. delta application).
> 
> 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", a term
> often invoked to indicate permanent data destruction.
> 
> diff -r 4ddf6bdba3e2 -r c0a3869d01b0 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,11 @@
>      """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, node, metadata):
> +        self.node = node
> +        self.metadata = metadata
> +        from node import short
> +        RevlogError.__init__(self, 'censored node %s' % short(node))

Wants _(). Maybe wants to take a filename? Dunno about metadata.

Patch

diff -r 4ddf6bdba3e2 -r c0a3869d01b0 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,11 @@ 
     """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, node, metadata):
+        self.node = node
+        self.metadata = metadata
+        from node import short
+        RevlogError.__init__(self, 'censored node %s' % short(node))