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

login
register
mail settings
Submitter michaeljedgar@gmail.com
Date Sept. 15, 2014, 12:01 p.m.
Message ID <264440edaa441525b98e.1410782485@adgar-macbookpro3.roam.corp.google.com>
Download mbox | patch
Permalink /patch/5826/
State Accepted
Headers show

Comments

michaeljedgar@gmail.com - Sept. 15, 2014, 12:01 p.m.
# HG changeset patch
# User Mike Edgar <adgar@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.

Patch

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."""