diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -295,8 +295,9 @@ class changelog(revlog.revlog): 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 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 @@ Version 2 revlogs have the following fla 0 Store revision data inline. -1 - Generaldelta encoding. The following header values are common: @@ -159,8 +157,10 @@ Version 2 Format (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/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -363,7 +363,7 @@ class locallegacypeer(localpeer): # 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/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -387,8 +387,7 @@ class revlog(object): 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 @@ class revlog(object): 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/revlogutils/constants.py b/mercurial/revlogutils/constants.py --- a/mercurial/revlogutils/constants.py +++ b/mercurial/revlogutils/constants.py @@ -20,13 +20,15 @@ REVLOGV1 = 1 # 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/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 @@ Can create and open repo with revlog v2 $ cd empty-repo $ cat .hg/requires dotencode - exp-revlogv2.0 + exp-revlogv2.1 fncache sparserevlog store @@ -54,7 +54,7 @@ Writing a simple revlog v2 works 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: @@ -62,4 +62,4 @@ Header written as expected (changelog al $ f --hexdump --bytes 4 .hg/store/data/foo.i .hg/store/data/foo.i: - 0000: 00 03 de ad |....| + 0000: 00 01 de ad |....|