Show More
@@ -91,7 +91,7 class simplefilestoreproblem(object): | |||
|
91 | 91 | node = attr.ib(default=None) |
|
92 | 92 | |
|
93 | 93 | @interfaceutil.implementer(repository.ifilestorage) |
|
94 | class filestorage(object): | |
|
94 | class filestorage(flagutil.flagprocessorsmixin): | |
|
95 | 95 | """Implements storage for a tracked path. |
|
96 | 96 | |
|
97 | 97 | Data is stored in the VFS in a directory corresponding to the tracked |
@@ -102,6 +102,8 class filestorage(object): | |||
|
102 | 102 | Fulltext data is stored in files having names of the node. |
|
103 | 103 | """ |
|
104 | 104 | |
|
105 | _flagserrorclass = simplestoreerror | |
|
106 | ||
|
105 | 107 | def __init__(self, svfs, path): |
|
106 | 108 | self._svfs = svfs |
|
107 | 109 | self._path = path |
@@ -119,6 +121,8 class filestorage(object): | |||
|
119 | 121 | self._index = [] |
|
120 | 122 | self._refreshindex() |
|
121 | 123 | |
|
124 | self._flagprocessors = dict(flagutil.flagprocessors) | |
|
125 | ||
|
122 | 126 | def _refreshindex(self): |
|
123 | 127 | self._indexbynode.clear() |
|
124 | 128 | self._indexbyrev.clear() |
@@ -263,45 +267,6 class filestorage(object): | |||
|
263 | 267 | |
|
264 | 268 | return True |
|
265 | 269 | |
|
266 | def _processflags(self, text, flags, operation, raw=False): | |
|
267 | if flags == 0: | |
|
268 | return text, True | |
|
269 | ||
|
270 | if flags & ~flagutil.REVIDX_KNOWN_FLAGS: | |
|
271 | raise simplestoreerror(_("incompatible revision flag '%#x'") % | |
|
272 | (flags & ~flagutil.REVIDX_KNOWN_FLAGS)) | |
|
273 | ||
|
274 | validatehash = True | |
|
275 | # Depending on the operation (read or write), the order might be | |
|
276 | # reversed due to non-commutative transforms. | |
|
277 | orderedflags = revlog.REVIDX_FLAGS_ORDER | |
|
278 | if operation == 'write': | |
|
279 | orderedflags = reversed(orderedflags) | |
|
280 | ||
|
281 | for flag in orderedflags: | |
|
282 | # If a flagprocessor has been registered for a known flag, apply the | |
|
283 | # related operation transform and update result tuple. | |
|
284 | if flag & flags: | |
|
285 | vhash = True | |
|
286 | ||
|
287 | if flag not in revlog._flagprocessors: | |
|
288 | message = _("missing processor for flag '%#x'") % (flag) | |
|
289 | raise simplestoreerror(message) | |
|
290 | ||
|
291 | processor = revlog._flagprocessors[flag] | |
|
292 | if processor is not None: | |
|
293 | readtransform, writetransform, rawtransform = processor | |
|
294 | ||
|
295 | if raw: | |
|
296 | vhash = rawtransform(self, text) | |
|
297 | elif operation == 'read': | |
|
298 | text, vhash = readtransform(self, text) | |
|
299 | else: # write operation | |
|
300 | text, vhash = writetransform(self, text) | |
|
301 | validatehash = validatehash and vhash | |
|
302 | ||
|
303 | return text, validatehash | |
|
304 | ||
|
305 | 270 | def checkhash(self, text, node, p1=None, p2=None, rev=None): |
|
306 | 271 | if p1 is None and p2 is None: |
|
307 | 272 | p1, p2 = self.parents(node) |
General Comments 0
You need to be logged in to leave comments.
Login now