D5561: revlog: always enable generaldelta on version 2 revlogs
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Fri Jan 11 00:34:00 UTC 2019
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This commit starts the process of diverging version 2 revlogs
from version 1 revlogs.
generaldelta is a useful feature and has been enabled by
default for ages. I can't think of a good reason why the
feature should be disabled. Yes, it is true changelogs
today don't have generaldelta enabled. But that's because
they don't have delta chains enabled, so generaldelta makes
no sense there.
This commit makes generaldelta always enabled on version 2
revlogs.
As part of this, one-off code in changelog.py mucking with
revlog.version had to be made conditional on the revlog
version, as we don't want to change revlog feature
flags on version 2 revlogs. The fact this code exists
is horrible and stems from revlog options being shared by
the opener. We probably want a better API here. But that can
wait for another patch.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5561
AFFECTED FILES
mercurial/changelog.py
mercurial/help/internals/revlogs.txt
mercurial/localrepo.py
mercurial/revlog.py
mercurial/revlogutils/constants.py
tests/test-revlog-v2.t
CHANGE DETAILS
diff --git a/tests/test-revlog-v2.t b/tests/test-revlog-v2.t
--- a/tests/test-revlog-v2.t
+++ b/tests/test-revlog-v2.t
@@ -22,7 +22,7 @@
$ cd empty-repo
$ cat .hg/requires
dotencode
- exp-revlogv2.0
+ exp-revlogv2.1
fncache
sparserevlog
store
@@ -54,12 +54,12 @@
date: Thu Jan 01 00:00:00 1970 +0000
summary: initial
-Header written as expected (changelog always disables generaldelta)
+Header written as expected
$ f --hexdump --bytes 4 .hg/store/00changelog.i
.hg/store/00changelog.i:
0000: 00 01 de ad |....|
$ f --hexdump --bytes 4 .hg/store/data/foo.i
.hg/store/data/foo.i:
- 0000: 00 03 de ad |....|
+ 0000: 00 01 de ad |....|
diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -20,13 +20,15 @@
# Dummy value until file format is finalized.
# Reminder: change the bounds check in revlog.__init__ when this is changed.
REVLOGV2 = 0xDEAD
+# Shared across v1 and v2.
FLAG_INLINE_DATA = (1 << 16)
+# Only used by v1, implied by v2.
FLAG_GENERALDELTA = (1 << 17)
REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
REVLOG_DEFAULT_FORMAT = REVLOGV1
REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
-REVLOGV2_FLAGS = REVLOGV1_FLAGS
+REVLOGV2_FLAGS = FLAG_INLINE_DATA
# revlog index flags
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -387,8 +387,7 @@
opts = getattr(opener, 'options', {}) or {}
if 'revlogv2' in opts:
- # version 2 revlogs always use generaldelta.
- versionflags = REVLOGV2 | FLAG_GENERALDELTA | FLAG_INLINE_DATA
+ versionflags = REVLOGV2 | FLAG_INLINE_DATA
elif 'revlogv1' in opts:
versionflags = REVLOGV1 | FLAG_INLINE_DATA
if 'generaldelta' in opts:
@@ -451,25 +450,38 @@
raise
self.version = versionflags
- self._inline = versionflags & FLAG_INLINE_DATA
- self._generaldelta = versionflags & FLAG_GENERALDELTA
+
flags = versionflags & ~0xFFFF
fmt = versionflags & 0xFFFF
+
if fmt == REVLOGV0:
if flags:
raise error.RevlogError(_('unknown flags (%#04x) in version %d '
'revlog %s') %
(flags >> 16, fmt, self.indexfile))
+
+ self._inline = False
+ self._generaldelta = False
+
elif fmt == REVLOGV1:
if flags & ~REVLOGV1_FLAGS:
raise error.RevlogError(_('unknown flags (%#04x) in version %d '
'revlog %s') %
(flags >> 16, fmt, self.indexfile))
+
+ self._inline = versionflags & FLAG_INLINE_DATA
+ self._generaldelta = versionflags & FLAG_GENERALDELTA
+
elif fmt == REVLOGV2:
if flags & ~REVLOGV2_FLAGS:
raise error.RevlogError(_('unknown flags (%#04x) in version %d '
'revlog %s') %
(flags >> 16, fmt, self.indexfile))
+
+ self._inline = versionflags & FLAG_INLINE_DATA
+ # generaldelta implied by version 2 revlogs.
+ self._generaldelta = True
+
else:
raise error.RevlogError(_('unknown version (%d) in revlog %s') %
(fmt, self.indexfile))
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -363,7 +363,7 @@
# Increment the sub-version when the revlog v2 format changes to lock out old
# clients.
-REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'
+REVLOGV2_REQUIREMENT = 'exp-revlogv2.1'
# A repository with the sparserevlog feature will have delta chains that
# can spread over a larger span. Sparse reading cuts these large spans into
diff --git a/mercurial/help/internals/revlogs.txt b/mercurial/help/internals/revlogs.txt
--- a/mercurial/help/internals/revlogs.txt
+++ b/mercurial/help/internals/revlogs.txt
@@ -66,8 +66,6 @@
0
Store revision data inline.
-1
- Generaldelta encoding.
The following header values are common:
@@ -159,8 +157,10 @@
(In development. Format not finalized or stable.)
-Version 2 is currently identical to version 1. This will obviously
-change.
+Version 2 is identical to version 2 with the following differences.
+
+There is no dedicated *generaldelta* revlog format flag. Instead,
+the feature is implied enabled by default.
Delta Chains
============
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -295,8 +295,9 @@
revlog.revlog.__init__(self, opener, indexfile, datafile=datafile,
checkambig=True, mmaplargeindex=True)
- if self._initempty:
- # changelogs don't benefit from generaldelta
+ if self._initempty and (self.version & 0xFFFF == revlog.REVLOGV1):
+ # changelogs don't benefit from generaldelta.
+
self.version &= ~revlog.FLAG_GENERALDELTA
self._generaldelta = False
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list