[Updated] D10622: revlog: unify flag processing when loading index
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon May 17 13:01:19 UTC 2021
Closed by commit rHG4d1c893b9095: revlog: unify flag processing when loading index (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D10622?vs=27994&id=28022
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D10622/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D10622
AFFECTED FILES
mercurial/revlog.py
mercurial/revlogutils/constants.py
CHANGE DETAILS
diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -120,4 +120,34 @@
REVLOGV2: REVLOGV2_FLAGS,
}
+_no = lambda flags: False
+_yes = lambda flags: True
+
+
+def _from_flag(flag):
+ return lambda flags: bool(flags & flag)
+
+
+FEATURES_BY_VERSION = {
+ REVLOGV0: {
+ b'inline': _no,
+ b'generaldelta': _no,
+ b'sidedata': False,
+ },
+ REVLOGV1: {
+ b'inline': _from_flag(FLAG_INLINE_DATA),
+ b'generaldelta': _from_flag(FLAG_GENERALDELTA),
+ b'sidedata': False,
+ },
+ REVLOGV2: {
+ # There is a bug in the transaction handling when going from an
+ # inline revlog to a separate index and data file. Turn it off until
+ # it's fixed, since v2 revlogs sometimes get rewritten on exchange.
+ # See issue6485
+ b'inline': _no,
+ b'generaldelta': _yes,
+ b'sidedata': True,
+ },
+}
+
SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -35,6 +35,7 @@
from .pycompat import getattr
from .revlogutils.constants import (
ALL_KINDS,
+ FEATURES_BY_VERSION,
FLAG_GENERALDELTA,
FLAG_INLINE_DATA,
INDEX_HEADER,
@@ -499,24 +500,10 @@
msg %= (display_flag, self._format_version, self.display_id)
raise error.RevlogError(msg)
- if self._format_version == REVLOGV0:
- self._inline = False
- self._generaldelta = False
- elif self._format_version == REVLOGV1:
- self._inline = self._format_flags & FLAG_INLINE_DATA
- self._generaldelta = self._format_flags & FLAG_GENERALDELTA
- elif self._format_version == REVLOGV2:
- # There is a bug in the transaction handling when going from an
- # inline revlog to a separate index and data file. Turn it off until
- # it's fixed, since v2 revlogs sometimes get rewritten on exchange.
- # See issue6485
- self._inline = False
- # generaldelta implied by version 2 revlogs.
- self._generaldelta = True
- # revlog-v2 has built in sidedata support
- self.hassidedata = True
- else:
- assert False, 'unreachable'
+ features = FEATURES_BY_VERSION[self._format_version]
+ self._inline = features[b'inline'](self._format_flags)
+ self._generaldelta = features[b'generaldelta'](self._format_flags)
+ self.hassidedata = features[b'sidedata']
index_data = entry_data
self._indexfile = entry_point
To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210517/cef6958b/attachment-0002.html>
More information about the Mercurial-patches
mailing list