D6797: flagutil: use the new mixin use in remotefilelog

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Sat Sep 7 09:26:46 UTC 2019


marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

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

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6797

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py

CHANGE DETAILS

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.utils import storageutil
 
+from mercurial.revlogutils import flagutil
+
 from . import (
     constants,
     fileserverclient,
@@ -45,7 +47,7 @@
             raise KeyError(node)
         return node
 
-class remotefilelog(object):
+class remotefilelog(flagutil.flagprocessorsmixin):
 
     _generaldelta = True
 
@@ -57,6 +59,8 @@
 
         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 @@
     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



To: marmoute, yuja, durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list