Patchwork [1,of,2,v3] context: handle censored data in an on-disk file context based on config

login
register
mail settings
Submitter adgar@google.com
Date Oct. 14, 2014, 8:22 p.m.
Message ID <35378c7c4440e27bd156.1413318162@adgar.nyc.corp.google.com>
Download mbox | patch
Permalink /patch/6254/
State Accepted
Headers show

Comments

adgar@google.com - Oct. 14, 2014, 8:22 p.m.
# HG changeset patch
# User Mike Edgar <adgar@google.com>
# Date 1413315976 14400
#      Tue Oct 14 15:46:16 2014 -0400
# Node ID 35378c7c4440e27bd1569ec55d18e0f036209eca
# Parent  32533d333ad47871be09852129a47c02d3d3c169
context: handle censored data in an on-disk file context based on config

Two possible behaviors are defined for handling censored data: abort, and
ignore. When we ignore censored data we return an empty file to callers
requesting the file data.
Matt Mackall - Oct. 14, 2014, 9:25 p.m.
On Tue, 2014-10-14 at 16:22 -0400, adgar@google.com wrote:
> # HG changeset patch
> # User Mike Edgar <adgar@google.com>
> # Date 1413315976 14400
> #      Tue Oct 14 15:46:16 2014 -0400
> # Node ID 35378c7c4440e27bd1569ec55d18e0f036209eca
> # Parent  32533d333ad47871be09852129a47c02d3d3c169
> context: handle censored data in an on-disk file context based on config
> 
> Two possible behaviors are defined for handling censored data: abort, and
> ignore. When we ignore censored data we return an empty file to callers
> requesting the file data.
> 
> diff -r 32533d333ad4 -r 35378c7c4440 mercurial/context.py
> --- a/mercurial/context.py	Fri Oct 10 10:34:52 2014 -0400
> +++ b/mercurial/context.py	Tue Oct 14 15:46:16 2014 -0400
> @@ -930,7 +930,14 @@
>                         filelog=self._filelog)
>  
>      def data(self):
> -        return self._filelog.read(self._filenode)
> +        try:
> +            self._filelog.read(self._filenode)

The None object sends its regards. Fixed in flight.

Patch

diff -r 32533d333ad4 -r 35378c7c4440 mercurial/context.py
--- a/mercurial/context.py	Fri Oct 10 10:34:52 2014 -0400
+++ b/mercurial/context.py	Tue Oct 14 15:46:16 2014 -0400
@@ -930,7 +930,14 @@ 
                        filelog=self._filelog)
 
     def data(self):
-        return self._filelog.read(self._filenode)
+        try:
+            self._filelog.read(self._filenode)
+        except error.CensoredNodeError:
+            if self._repo.ui.config("censor", "policy", "abort") == "ignore":
+                return ""
+            raise util.Abort(_("censored node: %s") % short(self._filenode),
+                             hint="set censor.policy to ignore errors")
+
     def size(self):
         return self._filelog.size(self._filerev)