##// END OF EJS Templates
flagprocessors: make `processflagsread` a module level function...
marmoute -
r43261:eb5048f8 default
parent child Browse files
Show More
@@ -328,8 +328,7 b' class remotefilelog(flagutil.flagprocess'
328 flags = store.getmeta(self.filename, node).get(constants.METAKEYFLAG, 0)
328 flags = store.getmeta(self.filename, node).get(constants.METAKEYFLAG, 0)
329 if flags == 0:
329 if flags == 0:
330 return rawtext
330 return rawtext
331 text, verifyhash, sidedata = self._processflagsread(rawtext, flags)
331 return flagutil.processflagsread(self, rawtext, flags)[0]
332 return text
333
332
334 def rawdata(self, node):
333 def rawdata(self, node):
335 return self.revision(node, raw=False)
334 return self.revision(node, raw=False)
@@ -1663,7 +1663,7 b' class revlog(flagutil.flagprocessorsmixi'
1663 validatehash = self._processflagsraw(rawtext, flags)
1663 validatehash = self._processflagsraw(rawtext, flags)
1664 text = rawtext
1664 text = rawtext
1665 else:
1665 else:
1666 r = self._processflagsread(rawtext, flags)
1666 r = flagutil.processflagsread(self, rawtext, flags)
1667 text, validatehash, sidedata = r
1667 text, validatehash, sidedata = r
1668 if validatehash:
1668 if validatehash:
1669 self.checkhash(text, node, rev=rev)
1669 self.checkhash(text, node, rev=rev)
@@ -96,30 +96,10 b' class flagprocessorsmixin(object):'
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 processflagsread(self, text, flags)
100 else: # write operation
100 else: # write operation
101 return processflagswrite(self, text, flags)
101 return processflagswrite(self, text, flags)
102
102
103 def _processflagsread(self, text, flags):
104 """Inspect revision data flags and applies read transformations defined
105 by registered flag processors.
106
107 ``text`` - the revision data to process
108 ``flags`` - the revision flags
109 ``raw`` - an optional argument describing if the raw transform should be
110 applied.
111
112 This method processes the flags in the order (or reverse order if
113 ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
114 flag processors registered for present flags. The order of flags defined
115 in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
116
117 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
118 processed text and ``validatehash`` is a bool indicating whether the
119 returned text should be checked for hash integrity.
120 """
121 return _processflagsfunc(self, text, flags, 'read')
122
123 def _processflagsraw(self, text, flags):
103 def _processflagsraw(self, text, flags):
124 """Inspect revision data flags to check is the content hash should be
104 """Inspect revision data flags to check is the content hash should be
125 validated.
105 validated.
@@ -157,6 +137,26 b' def processflagswrite(revlog, text, flag'
157 return _processflagsfunc(revlog, text, flags, 'write',
137 return _processflagsfunc(revlog, text, flags, 'write',
158 sidedata=sidedata)[:2]
138 sidedata=sidedata)[:2]
159
139
140 def processflagsread(revlog, text, flags):
141 """Inspect revision data flags and applies read transformations defined
142 by registered flag processors.
143
144 ``text`` - the revision data to process
145 ``flags`` - the revision flags
146 ``raw`` - an optional argument describing if the raw transform should be
147 applied.
148
149 This method processes the flags in the order (or reverse order if
150 ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
151 flag processors registered for present flags. The order of flags defined
152 in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
153
154 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
155 processed text and ``validatehash`` is a bool indicating whether the
156 returned text should be checked for hash integrity.
157 """
158 return _processflagsfunc(revlog, text, flags, 'read')
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
@@ -294,7 +294,7 b' class filestorage(flagutil.flagprocessor'
294 validatehash = self._processflagsraw(rawtext, flags)
294 validatehash = self._processflagsraw(rawtext, flags)
295 text = rawtext
295 text = rawtext
296 else:
296 else:
297 r = self._processflagsread(rawtext, flags)
297 r = flagutil.processflagsread(self, rawtext, flags)
298 text, validatehash, sidedata = r
298 text, validatehash, sidedata = r
299 if validatehash:
299 if validatehash:
300 self.checkhash(text, node, rev=rev)
300 self.checkhash(text, node, rev=rev)
General Comments 0
You need to be logged in to leave comments. Login now