comparison mercurial/revlogutils/flagutil.py @ 42992:a04b2c010d03

flagprocessors: make `processflagswrite` a module level function One more step towards removing the mixin. Differential Revision: https://phab.mercurial-scm.org/D6818
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 06 Sep 2019 23:50:32 +0200
parents 50d9de61ce02
children eb5048f8c533
comparison
equal deleted inserted replaced
42991:50d9de61ce02 42992:a04b2c010d03
96 if raw: 96 if raw:
97 return text, self._processflagsraw(text, flags) 97 return text, self._processflagsraw(text, flags)
98 elif operation == 'read': 98 elif operation == 'read':
99 return self._processflagsread(text, flags) 99 return self._processflagsread(text, flags)
100 else: # write operation 100 else: # write operation
101 return self._processflagswrite(text, flags) 101 return processflagswrite(self, text, flags)
102 102
103 def _processflagsread(self, text, flags): 103 def _processflagsread(self, text, flags):
104 """Inspect revision data flags and applies read transformations defined 104 """Inspect revision data flags and applies read transformations defined
105 by registered flag processors. 105 by registered flag processors.
106 106
118 processed text and ``validatehash`` is a bool indicating whether the 118 processed text and ``validatehash`` is a bool indicating whether the
119 returned text should be checked for hash integrity. 119 returned text should be checked for hash integrity.
120 """ 120 """
121 return _processflagsfunc(self, text, flags, 'read') 121 return _processflagsfunc(self, text, flags, 'read')
122 122
123 def _processflagswrite(self, text, flags, sidedata):
124 """Inspect revision data flags and applies write transformations defined
125 by registered flag processors.
126
127 ``text`` - the revision data to process
128 ``flags`` - the revision flags
129
130 This method processes the flags in the order (or reverse order if
131 ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
132 flag processors registered for present flags. The order of flags defined
133 in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
134
135 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
136 processed text and ``validatehash`` is a bool indicating whether the
137 returned text should be checked for hash integrity.
138 """
139 return _processflagsfunc(self, text, flags, 'write',
140 sidedata=sidedata)[:2]
141
142 def _processflagsraw(self, text, flags): 123 def _processflagsraw(self, text, flags):
143 """Inspect revision data flags to check is the content hash should be 124 """Inspect revision data flags to check is the content hash should be
144 validated. 125 validated.
145 126
146 ``text`` - the revision data to process 127 ``text`` - the revision data to process
154 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the 135 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
155 processed text and ``validatehash`` is a bool indicating whether the 136 processed text and ``validatehash`` is a bool indicating whether the
156 returned text should be checked for hash integrity. 137 returned text should be checked for hash integrity.
157 """ 138 """
158 return _processflagsfunc(self, text, flags, 'raw')[1] 139 return _processflagsfunc(self, text, flags, 'raw')[1]
140
141 def processflagswrite(revlog, text, flags, sidedata):
142 """Inspect revision data flags and applies write transformations defined
143 by registered flag processors.
144
145 ``text`` - the revision data to process
146 ``flags`` - the revision flags
147
148 This method processes the flags in the order (or reverse order if
149 ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
150 flag processors registered for present flags. The order of flags defined
151 in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
152
153 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
154 processed text and ``validatehash`` is a bool indicating whether the
155 returned text should be checked for hash integrity.
156 """
157 return _processflagsfunc(revlog, text, flags, 'write',
158 sidedata=sidedata)[:2]
159 159
160 def _processflagsfunc(revlog, text, flags, operation, sidedata=None): 160 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
161 """internal function to process flag on a revlog 161 """internal function to process flag on a revlog
162 162
163 This function is private to this module, code should never needs to call it 163 This function is private to this module, code should never needs to call it