changeset 39768:7b2b42fc377a

revlog: store flag processors per revlog Previously, revlog flag processing would consult a global dict when processing flags. This was simple. But it had the undesired side-effect that any extension could load flag processors once and those flag processors would be available to any revlog that was subsequent loaded in the process. e.g. in hgweb, if the narrow extension were loaded for repo A but not repo B, repo B would be able to decode ellipsis flags even though it shouldn't be able to. Making the flag processors dict per-revlog allows us to have per-revlog controls over what flag processors are available, thus preserving desired granular access to flag processors depending on the revlog's needs. If a flag processor is globally registered, it is still globally available. So this commit should not meaningfully change behavior. Differential Revision: https://phab.mercurial-scm.org/D4646
author Gregory Szorc <gregory.szorc@gmail.com>
date Thu, 13 Sep 2018 15:48:53 -0700
parents db088e133e91
children ba0e0c6b7b61
files mercurial/revlog.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed Sep 05 13:29:22 2018 -0700
+++ b/mercurial/revlog.py	Thu Sep 13 15:48:53 2018 -0700
@@ -415,6 +415,10 @@
         self._srdensitythreshold = 0.50
         self._srmingapsize = 262144
 
+        # Make copy of flag processors so each revlog instance can support
+        # custom flags.
+        self._flagprocessors = dict(_flagprocessors)
+
         mmapindexthreshold = None
         v = REVLOG_DEFAULT_VERSION
         opts = getattr(opener, 'options', None)
@@ -1707,11 +1711,11 @@
             if flag & flags:
                 vhash = True
 
-                if flag not in _flagprocessors:
+                if flag not in self._flagprocessors:
                     message = _("missing processor for flag '%#x'") % (flag)
                     raise RevlogError(message)
 
-                processor = _flagprocessors[flag]
+                processor = self._flagprocessors[flag]
                 if processor is not None:
                     readtransform, writetransform, rawtransform = processor