Mercurial > hg
changeset 26907:dfab6edb98e3
format: introduce 'format.usegeneraldelta`
This option will make repositories created as general delta by default but will
not make Mercurial aggressively recompute deltas for all incoming bundle.
Instead, the delta contained in the bundle will be used. This will allow us to
start having general delta repositories created everywhere without triggering
massive recomputation costs for all new clients cloning from old servers.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 02 Nov 2015 15:59:12 +0000 |
parents | e40af07e518e |
children | 150fb782ef80 |
files | mercurial/help/config.txt mercurial/localrepo.py mercurial/revlog.py mercurial/scmutil.py tests/test-generaldelta.t |
diffstat | 5 files changed, 67 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/help/config.txt Mon Nov 02 16:52:34 2015 +0000 +++ b/mercurial/help/config.txt Mon Nov 02 15:59:12 2015 +0000 @@ -666,6 +666,14 @@ ``format`` ---------- +``usegeneraldelta`` + Enable or disable the "generaldelta" repository format which improves + repository compression by allowing "revlog" to store delta against arbitrary + revision instead of the previous stored one. This provides significant + improvement for repositories with branches. Disabling this option ensures that + the on-disk format of newly created repository will be compatible with + Mercurial before version 1.9. + ``usestore`` Enable or disable the "store" repository format which improves compatibility with systems that fold case or otherwise mangle
--- a/mercurial/localrepo.py Mon Nov 02 16:52:34 2015 +0000 +++ b/mercurial/localrepo.py Mon Nov 02 15:59:12 2015 +0000 @@ -358,6 +358,7 @@ aggressivemergedeltas = self.ui.configbool('format', 'aggressivemergedeltas', False) self.svfs.options['aggressivemergedeltas'] = aggressivemergedeltas + self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui) def _writerequirements(self): scmutil.writerequires(self.vfs, self.requirements)
--- a/mercurial/revlog.py Mon Nov 02 16:52:34 2015 +0000 +++ b/mercurial/revlog.py Mon Nov 02 15:59:12 2015 +0000 @@ -230,6 +230,7 @@ self._maxchainlen = opts['maxchainlen'] if 'aggressivemergedeltas' in opts: self._aggressivemergedeltas = opts['aggressivemergedeltas'] + self._lazydeltabase = bool(opts.get('lazydeltabase', False)) if self._chunkcachesize <= 0: raise RevlogError(_('revlog chunk cache size %r is not greater ' @@ -1370,7 +1371,11 @@ # should we try to build a delta? if prev != nullrev: - if self._generaldelta: + if cachedelta and self._generaldelta and self._lazydeltabase: + # Assume what we received from the server is a good choice + # build delta will reuse the cache + d = builddelta(cachedelta[0]) + elif self._generaldelta: if p2r != nullrev and self._aggressivemergedeltas: d = builddelta(p1r) d2 = builddelta(p2r)
--- a/mercurial/scmutil.py Mon Nov 02 16:52:34 2015 +0000 +++ b/mercurial/scmutil.py Mon Nov 02 15:59:12 2015 +0000 @@ -1173,8 +1173,13 @@ def gdinitconfig(ui): """helper function to know if a repo should be created as general delta + """ + # experimental config: format.generaldelta + return (ui.configbool('format', 'generaldelta', False) + or ui.configbool('format', 'usegeneraldelta', False)) - This currently depends on a single config option but this will get more - complicated soon.""" +def gddeltaconfig(ui): + """helper function to know if incoming delta should be optimised + """ # experimental config: format.generaldelta return ui.configbool('format', 'generaldelta', False)
--- a/tests/test-generaldelta.t Mon Nov 02 16:52:34 2015 +0000 +++ b/tests/test-generaldelta.t Mon Nov 02 15:59:12 2015 +0000 @@ -71,10 +71,55 @@ $ cd .. +Test "usegeneraldelta" config +(repo are general delta, but incoming bundle are not re-deltified) + +delta coming from the server base delta server are not recompressed. +(also include the aggressive version for comparison) + + $ hg clone repo --pull --config format.usegeneraldelta=1 usegd + requesting all changes + adding changesets + adding manifests + adding file changes + added 4 changesets with 5 changes to 2 files (+2 heads) + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg clone repo --pull --config format.generaldelta=1 full + requesting all changes + adding changesets + adding manifests + adding file changes + added 4 changesets with 5 changes to 2 files (+2 heads) + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg -R repo debugindex -m + rev offset length base linkrev nodeid p1 p2 + 0 0 77 0 0 0273e8a1b972 000000000000 000000000000 + 1 77 57 0 1 e0c49f5ef780 0273e8a1b972 000000000000 + 2 134 77 2 2 de950093e41b 0273e8a1b972 000000000000 + 3 211 57 2 3 db74c7cde4d0 0273e8a1b972 000000000000 + $ hg -R usegd debugindex -m + rev offset length delta linkrev nodeid p1 p2 + 0 0 77 -1 0 0273e8a1b972 000000000000 000000000000 + 1 77 57 0 1 e0c49f5ef780 0273e8a1b972 000000000000 + 2 134 77 -1 2 de950093e41b 0273e8a1b972 000000000000 + 3 211 57 2 3 db74c7cde4d0 0273e8a1b972 000000000000 + $ hg -R full debugindex -m + rev offset length delta linkrev nodeid p1 p2 + 0 0 77 -1 0 0273e8a1b972 000000000000 000000000000 + 1 77 57 0 1 e0c49f5ef780 0273e8a1b972 000000000000 + 2 134 57 0 2 de950093e41b 0273e8a1b972 000000000000 + 3 191 57 0 3 db74c7cde4d0 0273e8a1b972 000000000000 + Test format.aggressivemergedeltas $ hg init --config format.generaldelta=1 aggressive $ cd aggressive + $ cat << EOF >> .hg/hgrc + > [format] + > generaldelta = 1 + > EOF $ touch a b c d e $ hg commit -Aqm side1 $ hg up -q null