From patchwork Mon Sep 15 12:01:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [1, of, 7, RFC, v2] error: add CensoredNodeError, will be thrown when content deliberately erased From: michaeljedgar@gmail.com X-Patchwork-Id: 5822 Message-Id: <0dc057ad6ad1e9ab481d.1410782482@adgar-macbookpro3.roam.corp.google.com> To: mercurial-devel@selenic.com Date: Mon, 15 Sep 2014 08:01:22 -0400 # HG changeset patch # User Mike Edgar # 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". 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)))