Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlogutils/flagutil.py @ 42888:3bed541aa65d
flagprocessors: small code update to clarify parameters
'raw' is really a third mode, not a small variant.
Differential Revision: https://phab.mercurial-scm.org/D6807
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 07 Sep 2019 10:08:47 -0700 |
parents | 519b45603880 |
children | a45d670c2bfc |
comparison
equal
deleted
inserted
replaced
42887:519b45603880 | 42888:3bed541aa65d |
---|---|
152 | 152 |
153 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the | 153 Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the |
154 processed text and ``validatehash`` is a bool indicating whether the | 154 processed text and ``validatehash`` is a bool indicating whether the |
155 returned text should be checked for hash integrity. | 155 returned text should be checked for hash integrity. |
156 """ | 156 """ |
157 return self._processflagsfunc(text, flags, 'read', raw=True)[1] | 157 return self._processflagsfunc(text, flags, 'raw')[1] |
158 | 158 |
159 def _processflagsfunc(self, text, flags, operation, raw=False): | 159 def _processflagsfunc(self, text, flags, operation): |
160 # fast path: no flag processors will run | 160 # fast path: no flag processors will run |
161 if flags == 0: | 161 if flags == 0: |
162 return text, True | 162 return text, True |
163 if not operation in ('read', 'write'): | 163 if operation not in ('read', 'write', 'raw'): |
164 raise error.ProgrammingError(_("invalid '%s' operation") % | 164 raise error.ProgrammingError(_("invalid '%s' operation") % |
165 operation) | 165 operation) |
166 # Check all flags are known. | 166 # Check all flags are known. |
167 if flags & ~REVIDX_KNOWN_FLAGS: | 167 if flags & ~REVIDX_KNOWN_FLAGS: |
168 raise self._flagserrorclass(_("incompatible revision flag '%#x'") % | 168 raise self._flagserrorclass(_("incompatible revision flag '%#x'") % |
186 | 186 |
187 processor = self._flagprocessors[flag] | 187 processor = self._flagprocessors[flag] |
188 if processor is not None: | 188 if processor is not None: |
189 readtransform, writetransform, rawtransform = processor | 189 readtransform, writetransform, rawtransform = processor |
190 | 190 |
191 if raw: | 191 if operation == 'raw': |
192 vhash = rawtransform(self, text) | 192 vhash = rawtransform(self, text) |
193 elif operation == 'read': | 193 elif operation == 'read': |
194 text, vhash = readtransform(self, text) | 194 text, vhash = readtransform(self, text) |
195 else: # write operation | 195 else: # write operation |
196 text, vhash = writetransform(self, text) | 196 text, vhash = writetransform(self, text) |