Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/constants.py @ 47231:4d1c893b9095
revlog: unify flag processing when loading index
The new code use a simple declaration to do centralised processing. This is
clearer, shorter and less error prone. This will be especially useful as we plan
to add a fourth format: changelog-v2.
Differential Revision: https://phab.mercurial-scm.org/D10622
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 03 May 2021 12:30:46 +0200 |
parents | 0e9105bf54cb |
children | 616b8f412676 |
comparison
equal
deleted
inserted
replaced
47230:0e9105bf54cb | 47231:4d1c893b9095 |
---|---|
118 REVLOGV0: REVLOGV0_FLAGS, | 118 REVLOGV0: REVLOGV0_FLAGS, |
119 REVLOGV1: REVLOGV1_FLAGS, | 119 REVLOGV1: REVLOGV1_FLAGS, |
120 REVLOGV2: REVLOGV2_FLAGS, | 120 REVLOGV2: REVLOGV2_FLAGS, |
121 } | 121 } |
122 | 122 |
123 _no = lambda flags: False | |
124 _yes = lambda flags: True | |
125 | |
126 | |
127 def _from_flag(flag): | |
128 return lambda flags: bool(flags & flag) | |
129 | |
130 | |
131 FEATURES_BY_VERSION = { | |
132 REVLOGV0: { | |
133 b'inline': _no, | |
134 b'generaldelta': _no, | |
135 b'sidedata': False, | |
136 }, | |
137 REVLOGV1: { | |
138 b'inline': _from_flag(FLAG_INLINE_DATA), | |
139 b'generaldelta': _from_flag(FLAG_GENERALDELTA), | |
140 b'sidedata': False, | |
141 }, | |
142 REVLOGV2: { | |
143 # There is a bug in the transaction handling when going from an | |
144 # inline revlog to a separate index and data file. Turn it off until | |
145 # it's fixed, since v2 revlogs sometimes get rewritten on exchange. | |
146 # See issue6485 | |
147 b'inline': _no, | |
148 b'generaldelta': _yes, | |
149 b'sidedata': True, | |
150 }, | |
151 } | |
152 | |
123 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000 | 153 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000 |