Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 39356:729082bb9938
revlog: split constants into a new `revlogutils.constants` module
We want to split some logic out of the main revlog file (the delta computing
logic). However, this logic needs access to multiple constants related to the
revlog. So we move all revlog related constants into a new module that could
be imported from multiple places.
We don't copy the file (preserving blame history) because there are only a few
moving lines. Also, copying the file would result in annoying merge conflicts
with ongoing work from others contributors.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 16 Aug 2018 02:08:13 +0200 |
parents | 0a5b20c107a6 |
children | 655b5b465953 |
comparison
equal
deleted
inserted
replaced
39355:94a4980695f8 | 39356:729082bb9938 |
---|---|
34 wdirhex, | 34 wdirhex, |
35 wdirid, | 35 wdirid, |
36 wdirrev, | 36 wdirrev, |
37 ) | 37 ) |
38 from .i18n import _ | 38 from .i18n import _ |
39 from .revlogutils.constants import ( | |
40 FLAG_GENERALDELTA, | |
41 FLAG_INLINE_DATA, | |
42 LIMIT_DELTA2TEXT, | |
43 REVIDX_DEFAULT_FLAGS, | |
44 REVIDX_ELLIPSIS, | |
45 REVIDX_EXTSTORED, | |
46 REVIDX_FLAGS_ORDER, | |
47 REVIDX_ISCENSORED, | |
48 REVIDX_KNOWN_FLAGS, | |
49 REVIDX_RAWTEXT_CHANGING_FLAGS, | |
50 REVLOGV0, | |
51 REVLOGV1, | |
52 REVLOGV1_FLAGS, | |
53 REVLOGV2, | |
54 REVLOGV2_FLAGS, | |
55 REVLOG_DEFAULT_FLAGS, | |
56 REVLOG_DEFAULT_FORMAT, | |
57 REVLOG_DEFAULT_VERSION, | |
58 ) | |
39 from .thirdparty import ( | 59 from .thirdparty import ( |
40 attr, | 60 attr, |
41 ) | 61 ) |
42 from . import ( | 62 from . import ( |
43 ancestor, | 63 ancestor, |
52 from .utils import ( | 72 from .utils import ( |
53 interfaceutil, | 73 interfaceutil, |
54 stringutil, | 74 stringutil, |
55 ) | 75 ) |
56 | 76 |
77 # blanked usage of all the name to prevent pyflakes constraints | |
78 # We need these name available in the module for extensions. | |
79 REVLOGV0 | |
80 REVLOGV1 | |
81 REVLOGV2 | |
82 FLAG_INLINE_DATA | |
83 FLAG_GENERALDELTA | |
84 REVLOG_DEFAULT_FLAGS | |
85 REVLOG_DEFAULT_FORMAT | |
86 REVLOG_DEFAULT_VERSION | |
87 REVLOGV1_FLAGS | |
88 REVLOGV2_FLAGS | |
89 REVIDX_ISCENSORED | |
90 REVIDX_ELLIPSIS | |
91 REVIDX_EXTSTORED | |
92 REVIDX_DEFAULT_FLAGS | |
93 REVIDX_FLAGS_ORDER | |
94 REVIDX_KNOWN_FLAGS | |
95 REVIDX_RAWTEXT_CHANGING_FLAGS | |
96 | |
57 parsers = policy.importmod(r'parsers') | 97 parsers = policy.importmod(r'parsers') |
58 | 98 |
59 # Aliased for performance. | 99 # Aliased for performance. |
60 _zlibdecompress = zlib.decompress | 100 _zlibdecompress = zlib.decompress |
61 | |
62 # revlog header flags | |
63 REVLOGV0 = 0 | |
64 REVLOGV1 = 1 | |
65 # Dummy value until file format is finalized. | |
66 # Reminder: change the bounds check in revlog.__init__ when this is changed. | |
67 REVLOGV2 = 0xDEAD | |
68 FLAG_INLINE_DATA = (1 << 16) | |
69 FLAG_GENERALDELTA = (1 << 17) | |
70 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA | |
71 REVLOG_DEFAULT_FORMAT = REVLOGV1 | |
72 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS | |
73 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA | |
74 REVLOGV2_FLAGS = REVLOGV1_FLAGS | |
75 | |
76 # revlog index flags | |
77 REVIDX_ISCENSORED = (1 << 15) # revision has censor metadata, must be verified | |
78 REVIDX_ELLIPSIS = (1 << 14) # revision hash does not match data (narrowhg) | |
79 REVIDX_EXTSTORED = (1 << 13) # revision data is stored externally | |
80 REVIDX_DEFAULT_FLAGS = 0 | |
81 # stable order in which flags need to be processed and their processors applied | |
82 REVIDX_FLAGS_ORDER = [ | |
83 REVIDX_ISCENSORED, | |
84 REVIDX_ELLIPSIS, | |
85 REVIDX_EXTSTORED, | |
86 ] | |
87 REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER) | |
88 # bitmark for flags that could cause rawdata content change | |
89 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED | |
90 | 101 |
91 # max size of revlog with inline data | 102 # max size of revlog with inline data |
92 _maxinline = 131072 | 103 _maxinline = 131072 |
93 _chunksize = 1048576 | 104 _chunksize = 1048576 |
94 | 105 |
851 class revlogoldindex(list): | 862 class revlogoldindex(list): |
852 def __getitem__(self, i): | 863 def __getitem__(self, i): |
853 if i == -1: | 864 if i == -1: |
854 return (0, 0, 0, -1, -1, -1, -1, nullid) | 865 return (0, 0, 0, -1, -1, -1, -1, nullid) |
855 return list.__getitem__(self, i) | 866 return list.__getitem__(self, i) |
856 | |
857 # maximum <delta-chain-data>/<revision-text-length> ratio | |
858 LIMIT_DELTA2TEXT = 2 | |
859 | 867 |
860 class revlogoldio(object): | 868 class revlogoldio(object): |
861 def __init__(self): | 869 def __init__(self): |
862 self.size = indexformatv0.size | 870 self.size = indexformatv0.size |
863 | 871 |