Patchwork [2,of,4,V2] flagutil: use the new mixin use in remotefilelog

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 11, 2019, 11:10 a.m.
Message ID <3093392949b15d637ba0.1565521848@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41243/
State New
Headers show

Comments

Pierre-Yves David - Aug. 11, 2019, 11:10 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1565219856 -7200
#      Thu Aug 08 01:17:36 2019 +0200
# Node ID 3093392949b15d637ba09fb63670631bc3e9462c
# Parent  e6d22ec889461dbe819e0dbf4d2f0167736b2416
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 3093392949b1
flagutil: use the new mixin use in remotefilelog

This remove one of the code duplication. Hooray \o/.

Patch

diff --git a/hgext/remotefilelog/remotefilelog.py b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -25,6 +25,8 @@  from mercurial import (
 )
 from mercurial.utils import storageutil
 
+from mercurial.revlogutils import flagutil
+
 from . import (
     constants,
     fileserverclient,
@@ -45,7 +47,7 @@  class remotefilelognodemap(object):
             raise KeyError(node)
         return node
 
-class remotefilelog(object):
+class remotefilelog(flagutil.flagprocessorsmixin):
 
     _generaldelta = True
 
@@ -57,6 +59,8 @@  class remotefilelog(object):
 
         self.version = 1
 
+        self._flagprocessors = dict(flagutil.flagprocessors)
+
     def read(self, node):
         """returns the file contents at this node"""
         t = self.revision(node)
@@ -327,28 +331,6 @@  class remotefilelog(object):
     def rawdata(self, node):
         return self.revision(node, raw=False)
 
-    def _processflags(self, text, flags, operation, raw=False):
-        # mostly copied from hg/mercurial/revlog.py
-        validatehash = True
-        orderedflags = revlog.REVIDX_FLAGS_ORDER
-        if operation == 'write':
-            orderedflags = reversed(orderedflags)
-        for flag in orderedflags:
-            if flag & flags:
-                vhash = True
-                if flag not in revlog._flagprocessors:
-                    message = _("missing processor for flag '%#x'") % (flag)
-                    raise revlog.RevlogError(message)
-                readfunc, writefunc, rawfunc = revlog._flagprocessors[flag]
-                if raw:
-                    vhash = rawfunc(self, text)
-                elif operation == 'read':
-                    text, vhash = readfunc(self, text)
-                elif operation == 'write':
-                    text, vhash = writefunc(self, text)
-                validatehash = validatehash and vhash
-        return text, validatehash
-
     def _read(self, id):
         """reads the raw file blob from disk, cache, or server"""
         fileservice = self.repo.fileservice