changeset 22932:d81792872984

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.
author Mike Edgar <adgar@google.com>
date Tue, 14 Oct 2014 15:46:16 -0400
parents 48c0b101a9de
children 3a60cd44e619
files mercurial/context.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Wed Oct 08 15:20:14 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:
+            return 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)