##// END OF EJS Templates
flagprocessors: make `processflagsraw` a module level function...
marmoute -
r43262:dff95420 default
parent child Browse files
Show More
@@ -1660,7 +1660,7 b' class revlog(flagutil.flagprocessorsmixi'
1660
1660
1661 sidedata = {}
1661 sidedata = {}
1662 if raw:
1662 if raw:
1663 validatehash = self._processflagsraw(rawtext, flags)
1663 validatehash = flagutil.processflagsraw(self, rawtext, flags)
1664 text = rawtext
1664 text = rawtext
1665 else:
1665 else:
1666 r = flagutil.processflagsread(self, rawtext, flags)
1666 r = flagutil.processflagsread(self, rawtext, flags)
@@ -33,6 +33,10 b' from .. import ('
33 util,
33 util,
34 )
34 )
35
35
36 from . import (
37 flagutil,
38 )
39
36 # maximum <delta-chain-data>/<revision-text-length> ratio
40 # maximum <delta-chain-data>/<revision-text-length> ratio
37 LIMIT_DELTA2TEXT = 2
41 LIMIT_DELTA2TEXT = 2
38
42
@@ -521,7 +525,7 b' def _textfromdelta(fh, revlog, baserev, '
521 fulltext = mdiff.patch(basetext, delta)
525 fulltext = mdiff.patch(basetext, delta)
522
526
523 try:
527 try:
524 validatehash = revlog._processflagsraw(fulltext, flags)
528 validatehash = flagutil.processflagsraw(revlog, fulltext, flags)
525 if validatehash:
529 if validatehash:
526 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
530 revlog.checkhash(fulltext, expectednode, p1=p1, p2=p2)
527 if flags & REVIDX_ISCENSORED:
531 if flags & REVIDX_ISCENSORED:
@@ -94,30 +94,12 b' class flagprocessorsmixin(object):'
94 msg = ('_processflag(...) use the specialized variant')
94 msg = ('_processflag(...) use the specialized variant')
95 util.nouideprecwarn(msg, '5.2', stacklevel=2)
95 util.nouideprecwarn(msg, '5.2', stacklevel=2)
96 if raw:
96 if raw:
97 return text, self._processflagsraw(text, flags)
97 return text, processflagsraw(self, text, flags)
98 elif operation == 'read':
98 elif operation == 'read':
99 return processflagsread(self, 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 _processflagsraw(self, text, flags):
104 """Inspect revision data flags to check is the content hash should be
105 validated.
106
107 ``text`` - the revision data to process
108 ``flags`` - the revision flags
109
110 This method processes the flags in the order (or reverse order if
111 ``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
112 flag processors registered for present flags. The order of flags defined
113 in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
114
115 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
116 processed text and ``validatehash`` is a bool indicating whether the
117 returned text should be checked for hash integrity.
118 """
119 return _processflagsfunc(self, text, flags, 'raw')[1]
120
121 def processflagswrite(revlog, text, flags, sidedata):
103 def processflagswrite(revlog, text, flags, sidedata):
122 """Inspect revision data flags and applies write transformations defined
104 """Inspect revision data flags and applies write transformations defined
123 by registered flag processors.
105 by registered flag processors.
@@ -157,6 +139,24 b' def processflagsread(revlog, text, flags'
157 """
139 """
158 return _processflagsfunc(revlog, text, flags, 'read')
140 return _processflagsfunc(revlog, text, flags, 'read')
159
141
142 def processflagsraw(revlog, text, flags):
143 """Inspect revision data flags to check is the content hash should be
144 validated.
145
146 ``text`` - the revision data to process
147 ``flags`` - the revision flags
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, 'raw')[1]
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
@@ -291,7 +291,7 b' class filestorage(flagutil.flagprocessor'
291 rawtext = self._svfs.read(path)
291 rawtext = self._svfs.read(path)
292
292
293 if raw:
293 if raw:
294 validatehash = self._processflagsraw(rawtext, flags)
294 validatehash = flagutil.processflagsraw(self, rawtext, flags)
295 text = rawtext
295 text = rawtext
296 else:
296 else:
297 r = flagutil.processflagsread(self, rawtext, flags)
297 r = flagutil.processflagsread(self, rawtext, flags)
General Comments 0
You need to be logged in to leave comments. Login now