##// END OF EJS Templates
flagprocessors: make `processflagswrite` a module level function...
marmoute -
r43260:a04b2c01 default
parent child Browse files
Show More
@@ -138,7 +138,7 b' class remotefilelog(flagutil.flagprocess'
138 138 sidedata = {}
139 139
140 140 meta, metaoffset = storageutil.parsemeta(text)
141 rawtext, validatehash = self._processflagswrite(text, flags,
141 rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
142 142 sidedata=sidedata)
143 143 return self.addrawrevision(rawtext, transaction, linknode, p1, p2,
144 144 node, flags, cachedelta,
@@ -1842,7 +1842,7 b' class revlog(flagutil.flagprocessorsmixi'
1842 1842 if flags:
1843 1843 node = node or self.hash(text, p1, p2)
1844 1844
1845 rawtext, validatehash = self._processflagswrite(text, flags,
1845 rawtext, validatehash = flagutil.processflagswrite(self, text, flags,
1846 1846 sidedata=sidedata)
1847 1847
1848 1848 # If the flag processor modifies the revision data, ignore any provided
@@ -98,7 +98,7 b' class flagprocessorsmixin(object):'
98 98 elif operation == 'read':
99 99 return self._processflagsread(text, flags)
100 100 else: # write operation
101 return self._processflagswrite(text, flags)
101 return processflagswrite(self, text, flags)
102 102
103 103 def _processflagsread(self, text, flags):
104 104 """Inspect revision data flags and applies read transformations defined
@@ -120,25 +120,6 b' class flagprocessorsmixin(object):'
120 120 """
121 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 123 def _processflagsraw(self, text, flags):
143 124 """Inspect revision data flags to check is the content hash should be
144 125 validated.
@@ -157,6 +138,25 b' class flagprocessorsmixin(object):'
157 138 """
158 139 return _processflagsfunc(self, text, flags, 'raw')[1]
159 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
160 160 def _processflagsfunc(revlog, text, flags, operation, sidedata=None):
161 161 """internal function to process flag on a revlog
162 162
@@ -457,7 +457,7 b' class filestorage(flagutil.flagprocessor'
457 457 if flags:
458 458 node = node or storageutil.hashrevisionsha1(text, p1, p2)
459 459
460 rawtext, validatehash = self._processflagswrite(text, flags)
460 rawtext, validatehash = flagutil.processflagswrite(self, text, flags)
461 461
462 462 node = node or storageutil.hashrevisionsha1(text, p1, p2)
463 463
General Comments 0
You need to be logged in to leave comments. Login now