Show More
@@ -118,7 +118,7 b' class flagprocessorsmixin(object):' | |||
|
118 | 118 | processed text and ``validatehash`` is a bool indicating whether the |
|
119 | 119 | returned text should be checked for hash integrity. |
|
120 | 120 | """ |
|
121 |
return |
|
|
121 | return _processflagsfunc(self, text, flags, 'read') | |
|
122 | 122 | |
|
123 | 123 | def _processflagswrite(self, text, flags, sidedata): |
|
124 | 124 | """Inspect revision data flags and applies write transformations defined |
@@ -136,8 +136,8 b' class flagprocessorsmixin(object):' | |||
|
136 | 136 | processed text and ``validatehash`` is a bool indicating whether the |
|
137 | 137 | returned text should be checked for hash integrity. |
|
138 | 138 | """ |
|
139 |
return |
|
|
140 |
|
|
|
139 | return _processflagsfunc(self, text, flags, 'write', | |
|
140 | sidedata=sidedata)[:2] | |
|
141 | 141 | |
|
142 | 142 | def _processflagsraw(self, text, flags): |
|
143 | 143 | """Inspect revision data flags to check is the content hash should be |
@@ -155,48 +155,52 b' class flagprocessorsmixin(object):' | |||
|
155 | 155 | processed text and ``validatehash`` is a bool indicating whether the |
|
156 | 156 | returned text should be checked for hash integrity. |
|
157 | 157 | """ |
|
158 |
return |
|
|
158 | return _processflagsfunc(self, text, flags, 'raw')[1] | |
|
159 | ||
|
160 | def _processflagsfunc(revlog, text, flags, operation, sidedata=None): | |
|
161 | """internal function to process flag on a revlog | |
|
159 | 162 |
|
|
160 | def _processflagsfunc(self, text, flags, operation, sidedata=None): | |
|
161 | # fast path: no flag processors will run | |
|
162 | if flags == 0: | |
|
163 | return text, True, {} | |
|
164 | if operation not in ('read', 'write', 'raw'): | |
|
165 | raise error.ProgrammingError(_("invalid '%s' operation") % | |
|
166 | operation) | |
|
167 | # Check all flags are known. | |
|
168 | if flags & ~REVIDX_KNOWN_FLAGS: | |
|
169 | raise self._flagserrorclass(_("incompatible revision flag '%#x'") % | |
|
170 | (flags & ~REVIDX_KNOWN_FLAGS)) | |
|
171 | validatehash = True | |
|
172 | # Depending on the operation (read or write), the order might be | |
|
173 | # reversed due to non-commutative transforms. | |
|
174 | orderedflags = REVIDX_FLAGS_ORDER | |
|
175 | if operation == 'write': | |
|
176 | orderedflags = reversed(orderedflags) | |
|
163 | This function is private to this module, code should never needs to call it | |
|
164 | directly.""" | |
|
165 | # fast path: no flag processors will run | |
|
166 | if flags == 0: | |
|
167 | return text, True, {} | |
|
168 | if operation not in ('read', 'write', 'raw'): | |
|
169 | raise error.ProgrammingError(_("invalid '%s' operation") % | |
|
170 | operation) | |
|
171 | # Check all flags are known. | |
|
172 | if flags & ~REVIDX_KNOWN_FLAGS: | |
|
173 | raise revlog._flagserrorclass(_("incompatible revision flag '%#x'") % | |
|
174 | (flags & ~REVIDX_KNOWN_FLAGS)) | |
|
175 | validatehash = True | |
|
176 | # Depending on the operation (read or write), the order might be | |
|
177 | # reversed due to non-commutative transforms. | |
|
178 | orderedflags = REVIDX_FLAGS_ORDER | |
|
179 | if operation == 'write': | |
|
180 | orderedflags = reversed(orderedflags) | |
|
177 | 181 | |
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
|
182 | outsidedata = {} | |
|
183 | for flag in orderedflags: | |
|
184 | # If a flagprocessor has been registered for a known flag, apply the | |
|
185 | # related operation transform and update result tuple. | |
|
186 | if flag & flags: | |
|
187 | vhash = True | |
|
184 | 188 | |
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
189 | if flag not in revlog._flagprocessors: | |
|
190 | message = _("missing processor for flag '%#x'") % (flag) | |
|
191 | raise revlog._flagserrorclass(message) | |
|
188 | 192 | |
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
193 | processor = revlog._flagprocessors[flag] | |
|
194 | if processor is not None: | |
|
195 | readtransform, writetransform, rawtransform = processor | |
|
192 | 196 | |
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
197 | if operation == 'raw': | |
|
198 | vhash = rawtransform(revlog, text) | |
|
199 | elif operation == 'read': | |
|
200 | text, vhash, s = readtransform(revlog, text) | |
|
201 | outsidedata.update(s) | |
|
202 | else: # write operation | |
|
203 | text, vhash = writetransform(revlog, text, sidedata) | |
|
204 | validatehash = validatehash and vhash | |
|
201 | 205 | |
|
202 |
|
|
|
206 | return text, validatehash, outsidedata |
General Comments 0
You need to be logged in to leave comments.
Login now