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