D6818: flagprocessors: make `processflagswrite` a module level function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

D6818: flagprocessors: make `processflagswrite` a module level function

martinvonz (Martin von Zweigbergk)
marmoute created this revision.
marmoute added reviewers: yuja, durin42.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One more step towards removing the mixin.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -457,7 +457,7 @@
         if flags:
             node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
 
         node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -98,7 +98,7 @@
         elif operation == 'read':
             return self._processflagsread(text, flags)
         else: # write operation
-            return self._processflagswrite(text, flags)
+            return processflagswrite(self, text, flags)
 
     def _processflagsread(self, text, flags):
         """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 @@
         """
         return _processflagsfunc(self, text, flags, 'read')
 
-    def _processflagswrite(self, text, flags, sidedata):
-        """Inspect revision data flags and applies write transformations defined
-        by registered flag processors.
-
-        ``text`` - the revision data to process
-        ``flags`` - the revision flags
-
-        This method processes the flags in the order (or reverse order if
-        ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-        flag processors registered for present flags. The order of flags defined
-        in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-        Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-        processed text and ``validatehash`` is a bool indicating whether the
-        returned text should be checked for hash integrity.
-        """
-        return _processflagsfunc(self, text, flags, 'write',
-                                 sidedata=sidedata)[:2]
-
     def _processflagsraw(self, text, flags):
         """Inspect revision data flags to check is the content hash should be
         validated.
@@ -157,6 +138,25 @@
         """
         return _processflagsfunc(self, text, flags, 'raw')[1]
 
+def processflagswrite(revlog, text, flags, sidedata):
+    """Inspect revision data flags and applies write transformations defined
+    by registered flag processors.
+
+    ``text`` - the revision data to process
+    ``flags`` - the revision flags
+
+    This method processes the flags in the order (or reverse order if
+    ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+    flag processors registered for present flags. The order of flags defined
+    in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+    Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+    processed text and ``validatehash`` is a bool indicating whether the
+    returned text should be checked for hash integrity.
+    """
+    return _processflagsfunc(revlog, text, flags, 'write',
+                             sidedata=sidedata)[:2]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
     """internal function to process flag on a revlog
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1836,8 +1836,8 @@
         if flags:
             node = node or self.hash(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
 
         # If the flag processor modifies the revision data, ignore any provided
         # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -136,8 +136,8 @@
             node = storageutil.hashrevisionsha1(text, p1, p2)
 
         meta, metaoffset = storageutil.parsemeta(text)
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
         return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
                                    node, flags, cachedelta,
                                    _metatuple=(meta, metaoffset))



To: marmoute, yuja, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6818: flagprocessors: make `processflagswrite` a module level function

martinvonz (Martin von Zweigbergk)
marmoute updated this revision to Diff 16484.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6818?vs=16423&id=16484

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6818/new/

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -457,7 +457,7 @@
         if flags:
             node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
 
         node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -98,7 +98,7 @@
         elif operation == 'read':
             return self._processflagsread(text, flags)
         else: # write operation
-            return self._processflagswrite(text, flags)
+            return processflagswrite(self, text, flags)
 
     def _processflagsread(self, text, flags):
         """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 @@
         """
         return _processflagsfunc(self, text, flags, 'read')
 
-    def _processflagswrite(self, text, flags, sidedata):
-        """Inspect revision data flags and applies write transformations defined
-        by registered flag processors.
-
-        ``text`` - the revision data to process
-        ``flags`` - the revision flags
-
-        This method processes the flags in the order (or reverse order if
-        ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-        flag processors registered for present flags. The order of flags defined
-        in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-        Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-        processed text and ``validatehash`` is a bool indicating whether the
-        returned text should be checked for hash integrity.
-        """
-        return _processflagsfunc(self, text, flags, 'write',
-                                 sidedata=sidedata)[:2]
-
     def _processflagsraw(self, text, flags):
         """Inspect revision data flags to check is the content hash should be
         validated.
@@ -157,6 +138,25 @@
         """
         return _processflagsfunc(self, text, flags, 'raw')[1]
 
+def processflagswrite(revlog, text, flags, sidedata):
+    """Inspect revision data flags and applies write transformations defined
+    by registered flag processors.
+
+    ``text`` - the revision data to process
+    ``flags`` - the revision flags
+
+    This method processes the flags in the order (or reverse order if
+    ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+    flag processors registered for present flags. The order of flags defined
+    in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+    Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+    processed text and ``validatehash`` is a bool indicating whether the
+    returned text should be checked for hash integrity.
+    """
+    return _processflagsfunc(revlog, text, flags, 'write',
+                             sidedata=sidedata)[:2]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
     """internal function to process flag on a revlog
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1843,8 +1843,8 @@
         if flags:
             node = node or self.hash(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
 
         # If the flag processor modifies the revision data, ignore any provided
         # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -135,8 +135,8 @@
             node = storageutil.hashrevisionsha1(text, p1, p2)
 
         meta, metaoffset = storageutil.parsemeta(text)
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
         return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
                                    node, flags, cachedelta,
                                    _metatuple=(meta, metaoffset))



To: marmoute, yuja, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6818: flagprocessors: make `processflagswrite` a module level function

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
marmoute updated this revision to Diff 16497.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6818?vs=16484&id=16497

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6818/new/

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -457,7 +457,7 @@
         if flags:
             node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
 
         node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -98,7 +98,7 @@
         elif operation == 'read':
             return self._processflagsread(text, flags)
         else: # write operation
-            return self._processflagswrite(text, flags)
+            return processflagswrite(self, text, flags)
 
     def _processflagsread(self, text, flags):
         """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 @@
         """
         return _processflagsfunc(self, text, flags, 'read')
 
-    def _processflagswrite(self, text, flags, sidedata):
-        """Inspect revision data flags and applies write transformations defined
-        by registered flag processors.
-
-        ``text`` - the revision data to process
-        ``flags`` - the revision flags
-
-        This method processes the flags in the order (or reverse order if
-        ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-        flag processors registered for present flags. The order of flags defined
-        in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-        Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-        processed text and ``validatehash`` is a bool indicating whether the
-        returned text should be checked for hash integrity.
-        """
-        return _processflagsfunc(self, text, flags, 'write',
-                                 sidedata=sidedata)[:2]
-
     def _processflagsraw(self, text, flags):
         """Inspect revision data flags to check is the content hash should be
         validated.
@@ -157,6 +138,25 @@
         """
         return _processflagsfunc(self, text, flags, 'raw')[1]
 
+def processflagswrite(revlog, text, flags, sidedata):
+    """Inspect revision data flags and applies write transformations defined
+    by registered flag processors.
+
+    ``text`` - the revision data to process
+    ``flags`` - the revision flags
+
+    This method processes the flags in the order (or reverse order if
+    ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+    flag processors registered for present flags. The order of flags defined
+    in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+    Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+    processed text and ``validatehash`` is a bool indicating whether the
+    returned text should be checked for hash integrity.
+    """
+    return _processflagsfunc(revlog, text, flags, 'write',
+                             sidedata=sidedata)[:2]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
     """internal function to process flag on a revlog
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1842,8 +1842,8 @@
         if flags:
             node = node or self.hash(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
 
         # If the flag processor modifies the revision data, ignore any provided
         # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -135,8 +135,8 @@
             node = storageutil.hashrevisionsha1(text, p1, p2)
 
         meta, metaoffset = storageutil.parsemeta(text)
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
         return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
                                    node, flags, cachedelta,
                                    _metatuple=(meta, metaoffset))



To: marmoute, yuja, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D6818: flagprocessors: make `processflagswrite` a module level function

martinvonz (Martin von Zweigbergk)
In reply to this post by martinvonz (Martin von Zweigbergk)
Closed by commit rHGa04b2c010d03: flagprocessors: make `processflagswrite` a module level function (authored by marmoute).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D6818?vs=16497&id=16637#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6818?vs=16497&id=16637

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6818/new/

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

AFFECTED FILES
  hgext/remotefilelog/remotefilelog.py
  mercurial/revlog.py
  mercurial/revlogutils/flagutil.py
  tests/simplestorerepo.py

CHANGE DETAILS

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -457,7 +457,7 @@
         if flags:
             node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
 
         node = node or storageutil.hashrevisionsha1(text, p1, p2)
 
diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -98,7 +98,7 @@
         elif operation == 'read':
             return self._processflagsread(text, flags)
         else: # write operation
-            return self._processflagswrite(text, flags)
+            return processflagswrite(self, text, flags)
 
     def _processflagsread(self, text, flags):
         """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 @@
         """
         return _processflagsfunc(self, text, flags, 'read')
 
-    def _processflagswrite(self, text, flags, sidedata):
-        """Inspect revision data flags and applies write transformations defined
-        by registered flag processors.
-
-        ``text`` - the revision data to process
-        ``flags`` - the revision flags
-
-        This method processes the flags in the order (or reverse order if
-        ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-        flag processors registered for present flags. The order of flags defined
-        in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-        Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-        processed text and ``validatehash`` is a bool indicating whether the
-        returned text should be checked for hash integrity.
-        """
-        return _processflagsfunc(self, text, flags, 'write',
-                                 sidedata=sidedata)[:2]
-
     def _processflagsraw(self, text, flags):
         """Inspect revision data flags to check is the content hash should be
         validated.
@@ -157,6 +138,25 @@
         """
         return _processflagsfunc(self, text, flags, 'raw')[1]
 
+def processflagswrite(revlog, text, flags, sidedata):
+    """Inspect revision data flags and applies write transformations defined
+    by registered flag processors.
+
+    ``text`` - the revision data to process
+    ``flags`` - the revision flags
+
+    This method processes the flags in the order (or reverse order if
+    ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
+    flag processors registered for present flags. The order of flags defined
+    in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
+
+    Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
+    processed text and ``validatehash`` is a bool indicating whether the
+    returned text should be checked for hash integrity.
+    """
+    return _processflagsfunc(revlog, text, flags, 'write',
+                             sidedata=sidedata)[:2]
+
 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
     """internal function to process flag on a revlog
 
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1842,8 +1842,8 @@
         if flags:
             node = node or self.hash(text, p1, p2)
 
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
 
         # If the flag processor modifies the revision data, ignore any provided
         # cachedelta.
diff --git a/hgext/remotefilelog/remotefilelog.py b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -138,8 +138,8 @@
             sidedata = {}
 
         meta, metaoffset = storageutil.parsemeta(text)
-        rawtext, validatehash = self._processflagswrite(text, flags,
-                                                        sidedata=sidedata)
+        rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
+                                                           sidedata=sidedata)
         return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
                                    node, flags, cachedelta,
                                    _metatuple=(meta, metaoffset))



To: marmoute, yuja, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel