changeset 42880:705428da231f

flagutil: use it in simplestorerepo This remove the other code duplication of the `_processflags` code. To be honest, this code looks very dead since it is not run by either developer nor buildbot. However, we update the code to make the task of reviving this less daunting. Differential Revision: https://phab.mercurial-scm.org/D6799
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 08 Aug 2019 02:10:18 +0200
parents 7907008a0bb5
children 87a934684c3b
files tests/simplestorerepo.py
diffstat 1 files changed, 5 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/tests/simplestorerepo.py	Thu Aug 08 01:15:44 2019 +0200
+++ b/tests/simplestorerepo.py	Thu Aug 08 02:10:18 2019 +0200
@@ -91,7 +91,7 @@
     node = attr.ib(default=None)
 
 @interfaceutil.implementer(repository.ifilestorage)
-class filestorage(object):
+class filestorage(flagutil.flagprocessorsmixin):
     """Implements storage for a tracked path.
 
     Data is stored in the VFS in a directory corresponding to the tracked
@@ -102,6 +102,8 @@
     Fulltext data is stored in files having names of the node.
     """
 
+    _flagserrorclass = simplestoreerror
+
     def __init__(self, svfs, path):
         self._svfs = svfs
         self._path = path
@@ -119,6 +121,8 @@
         self._index = []
         self._refreshindex()
 
+        self._flagprocessors = dict(flagutil.flagprocessors)
+
     def _refreshindex(self):
         self._indexbynode.clear()
         self._indexbyrev.clear()
@@ -263,45 +267,6 @@
 
         return True
 
-    def _processflags(self, text, flags, operation, raw=False):
-        if flags == 0:
-            return text, True
-
-        if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
-            raise simplestoreerror(_("incompatible revision flag '%#x'") %
-                                   (flags & ~flagutil.REVIDX_KNOWN_FLAGS))
-
-        validatehash = True
-        # Depending on the operation (read or write), the order might be
-        # reversed due to non-commutative transforms.
-        orderedflags = revlog.REVIDX_FLAGS_ORDER
-        if operation == 'write':
-            orderedflags = reversed(orderedflags)
-
-        for flag in orderedflags:
-            # If a flagprocessor has been registered for a known flag, apply the
-            # related operation transform and update result tuple.
-            if flag & flags:
-                vhash = True
-
-                if flag not in revlog._flagprocessors:
-                    message = _("missing processor for flag '%#x'") % (flag)
-                    raise simplestoreerror(message)
-
-                processor = revlog._flagprocessors[flag]
-                if processor is not None:
-                    readtransform, writetransform, rawtransform = processor
-
-                    if raw:
-                        vhash = rawtransform(self, text)
-                    elif operation == 'read':
-                        text, vhash = readtransform(self, text)
-                    else:  # write operation
-                        text, vhash = writetransform(self, text)
-                validatehash = validatehash and vhash
-
-        return text, validatehash
-
     def checkhash(self, text, node, p1=None, p2=None, rev=None):
         if p1 is None and p2 is None:
             p1, p2 = self.parents(node)