##// END OF EJS Templates
flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)...
marmoute -
r42956:92ac6b16 default
parent child Browse files
Show More
@@ -53,7 +53,6 b' from .revlogutils.flagutil import ('
53 53 REVIDX_EXTSTORED,
54 54 REVIDX_FLAGS_ORDER,
55 55 REVIDX_ISCENSORED,
56 REVIDX_KNOWN_FLAGS,
57 56 REVIDX_RAWTEXT_CHANGING_FLAGS,
58 57 )
59 58 from .thirdparty import (
@@ -97,7 +96,6 b' REVIDX_ELLIPSIS'
97 96 REVIDX_EXTSTORED
98 97 REVIDX_DEFAULT_FLAGS
99 98 REVIDX_FLAGS_ORDER
100 REVIDX_KNOWN_FLAGS
101 99 REVIDX_RAWTEXT_CHANGING_FLAGS
102 100
103 101 parsers = policy.importmod(r'parsers')
@@ -155,7 +153,7 b' def addflagprocessor(flag, processor):'
155 153 _insertflagprocessor(flag, processor, flagutil.flagprocessors)
156 154
157 155 def _insertflagprocessor(flag, processor, flagprocessors):
158 if not flag & REVIDX_KNOWN_FLAGS:
156 if not flag & flagutil.REVIDX_KNOWN_FLAGS:
159 157 msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
160 158 raise error.ProgrammingError(msg)
161 159 if flag not in REVIDX_FLAGS_ORDER:
@@ -173,7 +171,7 b' def gettype(q):'
173 171 return int(q & 0xFFFF)
174 172
175 173 def offset_type(offset, type):
176 if (type & ~REVIDX_KNOWN_FLAGS) != 0:
174 if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
177 175 raise ValueError('unknown revlog index flags')
178 176 return int(int(offset) << 16 | type)
179 177
@@ -685,7 +683,7 b' class revlog(object):'
685 683 # fast path: if no "read" flag processor could change the content,
686 684 # size is rawsize. note: ELLIPSIS is known to not change the content.
687 685 flags = self.flags(rev)
688 if flags & (REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0:
686 if flags & (flagutil.REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0:
689 687 return self.rawsize(rev)
690 688
691 689 return len(self.revision(rev, raw=False))
@@ -1762,9 +1760,9 b' class revlog(object):'
1762 1760 raise error.ProgrammingError(_("invalid '%s' operation") %
1763 1761 operation)
1764 1762 # Check all flags are known.
1765 if flags & ~REVIDX_KNOWN_FLAGS:
1763 if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
1766 1764 raise error.RevlogError(_("incompatible revision flag '%#x'") %
1767 (flags & ~REVIDX_KNOWN_FLAGS))
1765 (flags & ~flagutil.REVIDX_KNOWN_FLAGS))
1768 1766 validatehash = True
1769 1767 # Depending on the operation (read or write), the order might be
1770 1768 # reversed due to non-commutative transforms.
@@ -11,7 +11,6 b' from __future__ import absolute_import'
11 11
12 12 from .. import (
13 13 repository,
14 util,
15 14 )
16 15
17 16 # revlog header flags
@@ -48,7 +47,7 b' REVIDX_FLAGS_ORDER = ['
48 47 REVIDX_ELLIPSIS,
49 48 REVIDX_EXTSTORED,
50 49 ]
51 REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER)
50
52 51 # bitmark for flags that could cause rawdata content change
53 52 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED
54 53
@@ -14,10 +14,13 b' from .constants import ('
14 14 REVIDX_EXTSTORED,
15 15 REVIDX_FLAGS_ORDER,
16 16 REVIDX_ISCENSORED,
17 REVIDX_KNOWN_FLAGS,
18 17 REVIDX_RAWTEXT_CHANGING_FLAGS,
19 18 )
20 19
20 from .. import (
21 util
22 )
23
21 24 # blanked usage of all the name to prevent pyflakes constraints
22 25 # We need these name available in the module for extensions.
23 26 REVIDX_ISCENSORED
@@ -25,9 +28,10 b' REVIDX_ELLIPSIS'
25 28 REVIDX_EXTSTORED
26 29 REVIDX_DEFAULT_FLAGS
27 30 REVIDX_FLAGS_ORDER
28 REVIDX_KNOWN_FLAGS
29 31 REVIDX_RAWTEXT_CHANGING_FLAGS
30 32
33 REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER)
34
31 35 # Store flag processors (cf. 'addflagprocessor()' to register)
32 36 flagprocessors = {
33 37 REVIDX_ISCENSORED: None,
@@ -12,6 +12,9 b' from mercurial import ('
12 12 revlog,
13 13 util,
14 14 )
15 from mercurial.revlogutils import (
16 flagutil,
17 )
15 18
16 19 # Test only: These flags are defined here only in the context of testing the
17 20 # behavior of the flag processor. The canonical way to add flags is to get in
@@ -58,7 +61,7 b' def makewrappedfile(obj):'
58 61 class wrappedfile(obj.__class__):
59 62 def addrevision(self, text, transaction, link, p1, p2,
60 63 cachedelta=None, node=None,
61 flags=revlog.REVIDX_DEFAULT_FLAGS):
64 flags=flagutil.REVIDX_DEFAULT_FLAGS):
62 65 if b'[NOOP]' in text:
63 66 flags |= REVIDX_NOOP
64 67
@@ -102,7 +105,7 b' def extsetup(ui):'
102 105
103 106 # Teach revlog about our test flags
104 107 flags = [REVIDX_NOOP, REVIDX_BASE64, REVIDX_GZIP, REVIDX_FAIL]
105 revlog.REVIDX_KNOWN_FLAGS |= util.bitsfrom(flags)
108 flagutil.REVIDX_KNOWN_FLAGS |= util.bitsfrom(flags)
106 109 revlog.REVIDX_FLAGS_ORDER.extend(flags)
107 110
108 111 # Teach exchange to use changegroup 3
@@ -42,6 +42,9 b' from mercurial.utils import ('
42 42 interfaceutil,
43 43 storageutil,
44 44 )
45 from mercurial.revlogutils import (
46 flagutil,
47 )
45 48
46 49 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
47 50 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -262,9 +265,9 b' class filestorage(object):'
262 265 if flags == 0:
263 266 return text, True
264 267
265 if flags & ~revlog.REVIDX_KNOWN_FLAGS:
268 if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
266 269 raise simplestoreerror(_("incompatible revision flag '%#x'") %
267 (flags & ~revlog.REVIDX_KNOWN_FLAGS))
270 (flags & ~flagutil.REVIDX_KNOWN_FLAGS))
268 271
269 272 validatehash = True
270 273 # Depending on the operation (read or write), the order might be
General Comments 0
You need to be logged in to leave comments. Login now