Show More
@@ -150,19 +150,7 b' def addflagprocessor(flag, processor):' | |||||
150 | debug commands. In this case the transform only indicates whether the |
|
150 | debug commands. In this case the transform only indicates whether the | |
151 | contents can be used for hash integrity checks. |
|
151 | contents can be used for hash integrity checks. | |
152 | """ |
|
152 | """ | |
153 |
|
|
153 | flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors) | |
154 |
|
||||
155 | def _insertflagprocessor(flag, processor, flagprocessors): |
|
|||
156 | if not flag & flagutil.REVIDX_KNOWN_FLAGS: |
|
|||
157 | msg = _("cannot register processor on unknown flag '%#x'.") % (flag) |
|
|||
158 | raise error.ProgrammingError(msg) |
|
|||
159 | if flag not in REVIDX_FLAGS_ORDER: |
|
|||
160 | msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag) |
|
|||
161 | raise error.ProgrammingError(msg) |
|
|||
162 | if flag in flagprocessors: |
|
|||
163 | msg = _("cannot register multiple processors on flag '%#x'.") % (flag) |
|
|||
164 | raise error.Abort(msg) |
|
|||
165 | flagprocessors[flag] = processor |
|
|||
166 |
|
154 | |||
167 | def getoffset(q): |
|
155 | def getoffset(q): | |
168 | return int(q >> 16) |
|
156 | return int(q >> 16) | |
@@ -438,7 +426,7 b' class revlog(object):' | |||||
438 |
|
426 | |||
439 | # revlog v0 doesn't have flag processors |
|
427 | # revlog v0 doesn't have flag processors | |
440 | for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): |
|
428 | for flag, processor in opts.get(b'flagprocessors', {}).iteritems(): | |
441 |
|
|
429 | flagutil.insertflagprocessor(flag, processor, self._flagprocessors) | |
442 |
|
430 | |||
443 | if self._chunkcachesize <= 0: |
|
431 | if self._chunkcachesize <= 0: | |
444 | raise error.RevlogError(_('revlog chunk cache size %r is not ' |
|
432 | raise error.RevlogError(_('revlog chunk cache size %r is not ' |
@@ -8,6 +8,8 b'' | |||||
8 |
|
8 | |||
9 | from __future__ import absolute_import |
|
9 | from __future__ import absolute_import | |
10 |
|
10 | |||
|
11 | from ..i18n import _ | |||
|
12 | ||||
11 | from .constants import ( |
|
13 | from .constants import ( | |
12 | REVIDX_DEFAULT_FLAGS, |
|
14 | REVIDX_DEFAULT_FLAGS, | |
13 | REVIDX_ELLIPSIS, |
|
15 | REVIDX_ELLIPSIS, | |
@@ -18,6 +20,7 b' from .constants import (' | |||||
18 | ) |
|
20 | ) | |
19 |
|
21 | |||
20 | from .. import ( |
|
22 | from .. import ( | |
|
23 | error, | |||
21 | util |
|
24 | util | |
22 | ) |
|
25 | ) | |
23 |
|
26 | |||
@@ -37,3 +40,14 b' flagprocessors = {' | |||||
37 | REVIDX_ISCENSORED: None, |
|
40 | REVIDX_ISCENSORED: None, | |
38 | } |
|
41 | } | |
39 |
|
42 | |||
|
43 | def insertflagprocessor(flag, processor, flagprocessors): | |||
|
44 | if not flag & REVIDX_KNOWN_FLAGS: | |||
|
45 | msg = _("cannot register processor on unknown flag '%#x'.") % (flag) | |||
|
46 | raise error.ProgrammingError(msg) | |||
|
47 | if flag not in REVIDX_FLAGS_ORDER: | |||
|
48 | msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag) | |||
|
49 | raise error.ProgrammingError(msg) | |||
|
50 | if flag in flagprocessors: | |||
|
51 | msg = _("cannot register multiple processors on flag '%#x'.") % (flag) | |||
|
52 | raise error.Abort(msg) | |||
|
53 | flagprocessors[flag] = processor |
@@ -206,8 +206,8 b' Ensure the data got to the server OK' | |||||
206 | File "*/tests/flagprocessorext.py", line *, in extsetup (glob) |
|
206 | File "*/tests/flagprocessorext.py", line *, in extsetup (glob) | |
207 | validatehash, |
|
207 | validatehash, | |
208 | File "*/mercurial/revlog.py", line *, in addflagprocessor (glob) |
|
208 | File "*/mercurial/revlog.py", line *, in addflagprocessor (glob) | |
209 |
|
|
209 | flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors) | |
210 |
File "*/mercurial/revlog.py", line *, in |
|
210 | File "*/mercurial/revlogutils/flagutil.py", line *, in insertflagprocessor (glob) | |
211 | raise error.Abort(msg) |
|
211 | raise error.Abort(msg) | |
212 | mercurial.error.Abort: b"cannot register multiple processors on flag '0x8'." (py3 !) |
|
212 | mercurial.error.Abort: b"cannot register multiple processors on flag '0x8'." (py3 !) | |
213 | Abort: cannot register multiple processors on flag '0x8'. (no-py3 !) |
|
213 | Abort: cannot register multiple processors on flag '0x8'. (no-py3 !) |
General Comments 0
You need to be logged in to leave comments.
Login now