Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/flagutil.py @ 42873:7907008a0bb5
flagutil: make the error class used by the mixin configurable
One of the code duplication use a different error class. So let's make it
possible to do so.
Differential Revision: https://phab.mercurial-scm.org/D6798
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 08 Aug 2019 01:15:44 +0200 |
parents | 5bb68fb72df2 |
children | 87a934684c3b |
comparison
equal
deleted
inserted
replaced
42872:a5c088966d6c | 42873:7907008a0bb5 |
---|---|
85 Make sure the `_flagprocessors` attribute is set at ``__init__`` time. | 85 Make sure the `_flagprocessors` attribute is set at ``__init__`` time. |
86 | 86 |
87 See the documentation of the ``_processflags`` method for details. | 87 See the documentation of the ``_processflags`` method for details. |
88 """ | 88 """ |
89 | 89 |
90 _flagserrorclass = error.RevlogError | |
91 | |
90 def _processflags(self, text, flags, operation, raw=False): | 92 def _processflags(self, text, flags, operation, raw=False): |
91 """Inspect revision data flags and applies transforms defined by | 93 """Inspect revision data flags and applies transforms defined by |
92 registered flag processors. | 94 registered flag processors. |
93 | 95 |
94 ``text`` - the revision data to process | 96 ``text`` - the revision data to process |
115 if not operation in ('read', 'write'): | 117 if not operation in ('read', 'write'): |
116 raise error.ProgrammingError(_("invalid '%s' operation") % | 118 raise error.ProgrammingError(_("invalid '%s' operation") % |
117 operation) | 119 operation) |
118 # Check all flags are known. | 120 # Check all flags are known. |
119 if flags & ~REVIDX_KNOWN_FLAGS: | 121 if flags & ~REVIDX_KNOWN_FLAGS: |
120 raise error.RevlogError(_("incompatible revision flag '%#x'") % | 122 raise self._flagserrorclass(_("incompatible revision flag '%#x'") % |
121 (flags & ~REVIDX_KNOWN_FLAGS)) | 123 (flags & ~REVIDX_KNOWN_FLAGS)) |
122 validatehash = True | 124 validatehash = True |
123 # Depending on the operation (read or write), the order might be | 125 # Depending on the operation (read or write), the order might be |
124 # reversed due to non-commutative transforms. | 126 # reversed due to non-commutative transforms. |
125 orderedflags = REVIDX_FLAGS_ORDER | 127 orderedflags = REVIDX_FLAGS_ORDER |
126 if operation == 'write': | 128 if operation == 'write': |
132 if flag & flags: | 134 if flag & flags: |
133 vhash = True | 135 vhash = True |
134 | 136 |
135 if flag not in self._flagprocessors: | 137 if flag not in self._flagprocessors: |
136 message = _("missing processor for flag '%#x'") % (flag) | 138 message = _("missing processor for flag '%#x'") % (flag) |
137 raise error.RevlogError(message) | 139 raise self._flagserrorclass(message) |
138 | 140 |
139 processor = self._flagprocessors[flag] | 141 processor = self._flagprocessors[flag] |
140 if processor is not None: | 142 if processor is not None: |
141 readtransform, writetransform, rawtransform = processor | 143 readtransform, writetransform, rawtransform = processor |
142 | 144 |