[PATCH 4 of 7 RFC v2] context: new filectx helper 'censorallowed' verifies a censored file node

Mike Edgar michaeljedgar at gmail.com
Mon Sep 15 07:01:25 CDT 2014


# HG changeset patch
# User Mike Edgar <adgar at google.com>
# Date 1410727276 14400
#      Sun Sep 14 16:41:16 2014 -0400
# Node ID 264440edaa441525b98e776df76672304b7eb120
# Parent  0f5665410a9871b7303435ea3f76874a4b852e65
context: new filectx helper 'censorallowed' verifies a censored file node

This context helper simplifies verifying a node's censorship metadata by
providing access to the repository, its configuration, and the file path.

diff -r 0f5665410a98 -r 264440edaa44 mercurial/context.py
--- a/mercurial/context.py	Wed Sep 10 16:24:34 2014 -0400
+++ b/mercurial/context.py	Sun Sep 14 16:41:16 2014 -0400
@@ -7,7 +7,7 @@
 
 from node import nullid, nullrev, short, hex, bin
 from i18n import _
-import mdiff, error, util, scmutil, subrepo, patch, encoding, phases
+import censor, mdiff, error, util, scmutil, subrepo, patch, encoding, phases
 import match as matchmod
 import os, errno, stat
 import obsolete as obsmod
@@ -964,6 +964,9 @@
         return [filectx(self._repo, self._path, fileid=x,
                         filelog=self._filelog) for x in c]
 
+    def censorallowed(self):
+        return censor.allowed(self._repo, self._path, self._filenode)
+
 class committablectx(basectx):
     """A committablectx object provides common functionality for a context that
     wants the ability to commit, e.g. workingctx or memctx."""


More information about the Mercurial-devel mailing list