Mercurial > hg-stable
changeset 46165:41d695a08e90
bundle: optional advisory obsolescence parts
It is useful to ship obsolescence markers as part of clonebundles or
pullbundles, but they shouldn't stop a non-evolution client from working.
Differential Revision: https://phab.mercurial-scm.org/D8480
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 24 Apr 2020 16:36:04 +0200 |
parents | a27aa754d6ba |
children | c511fef30290 |
files | mercurial/bundle2.py mercurial/commands.py mercurial/configitems.py tests/test-obsolete-bundle-strip.t tests/test-obsolete-distributed.t tests/test-obsolete.t |
diffstat | 6 files changed, 102 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Thu Dec 17 09:35:07 2020 -0800 +++ b/mercurial/bundle2.py Fri Apr 24 16:36:04 2020 +0200 @@ -1739,7 +1739,11 @@ if opts.get(b'obsolescence', False): obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing) - buildobsmarkerspart(bundler, obsmarkers) + buildobsmarkerspart( + bundler, + obsmarkers, + mandatory=opts.get(b'obsolescence-mandatory', True), + ) if opts.get(b'phases', False): headsbyphase = phases.subsetphaseheads(repo, outgoing.missing) @@ -1862,7 +1866,7 @@ part.addparam(b'requirements', requirements, mandatory=True) -def buildobsmarkerspart(bundler, markers): +def buildobsmarkerspart(bundler, markers, mandatory=True): """add an obsmarker part to the bundler with <markers> No part is created if markers is empty. @@ -1876,7 +1880,7 @@ if version is None: raise ValueError(b'bundler does not support common obsmarker format') stream = obsolete.encodemarkers(markers, True, version=version) - return bundler.newpart(b'obsmarkers', data=stream) + return bundler.newpart(b'obsmarkers', data=stream, mandatory=mandatory) def writebundle(
--- a/mercurial/commands.py Thu Dec 17 09:35:07 2020 -0800 +++ b/mercurial/commands.py Fri Apr 24 16:36:04 2020 +0200 @@ -1648,12 +1648,17 @@ if complevel is not None: compopts[b'level'] = complevel - # Allow overriding the bundling of obsmarker in phases through - # configuration while we don't have a bundle version that include them - if repo.ui.configbool(b'experimental', b'evolution.bundle-obsmarker'): - bundlespec.contentopts[b'obsolescence'] = True - if repo.ui.configbool(b'experimental', b'bundle-phases'): - bundlespec.contentopts[b'phases'] = True + # Bundling of obsmarker and phases is optional as not all clients + # support the necessary features. + cfg = ui.configbool + contentopts = { + b'obsolescence': cfg(b'experimental', b'evolution.bundle-obsmarker'), + b'obsolescence-mandatory': cfg( + b'experimental', b'evolution.bundle-obsmarker:mandatory' + ), + b'phases': cfg(b'experimental', b'bundle-phases'), + } + bundlespec.contentopts.update(contentopts) bundle2.writenewbundle( ui,
--- a/mercurial/configitems.py Thu Dec 17 09:35:07 2020 -0800 +++ b/mercurial/configitems.py Fri Apr 24 16:36:04 2020 +0200 @@ -900,6 +900,11 @@ ) coreconfigitem( b'experimental', + b'evolution.bundle-obsmarker:mandatory', + default=True, +) +coreconfigitem( + b'experimental', b'log.topo', default=False, )
--- a/tests/test-obsolete-bundle-strip.t Thu Dec 17 09:35:07 2020 -0800 +++ b/tests/test-obsolete-bundle-strip.t Fri Apr 24 16:36:04 2020 +0200 @@ -1444,3 +1444,35 @@ # unbundling: new changesets 9ac430e15fca (1 drafts) # unbundling: (1 other changesets obsolete on arrival) # unbundling: (run 'hg update' to get a working copy) + +Test that advisory obsolescence markers in bundles are ignored if unsupported + + $ hg init repo-with-obs + $ cd repo-with-obs + $ hg debugbuilddag +1 + $ hg debugobsolete `getid 0` + 1 new obsolescence markers + obsoleted 1 changesets + $ hg bundle --config experimental.evolution.bundle-obsmarker=true --config experimental.evolution.bundle-obsmarker:mandatory=false --all --hidden bundle-with-obs + 1 changesets found + $ cd .. + $ hg init repo-without-obs + $ cd repo-without-obs + $ hg --config experimental.evolution=False unbundle ../repo-with-obs/bundle-with-obs --debug + bundle2-input-bundle: 1 params with-transaction + bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported + adding changesets + add changeset 1ea73414a91b + adding manifests + adding file changes + bundle2-input-part: total payload size 190 + bundle2-input-part: "cache:rev-branch-cache" (advisory) supported + bundle2-input-part: total payload size 39 + bundle2-input-part: "obsmarkers" (advisory) supported + bundle2-input-part: total payload size 50 + ignoring obsolescence markers, feature not enabled + bundle2-input-bundle: 3 parts total + updating the branch cache + added 1 changesets with 0 changes to 0 files + new changesets 1ea73414a91b (1 drafts) + (run 'hg update' to get a working copy)
--- a/tests/test-obsolete-distributed.t Thu Dec 17 09:35:07 2020 -0800 +++ b/tests/test-obsolete-distributed.t Fri Apr 24 16:36:04 2020 +0200 @@ -138,14 +138,42 @@ $ hg up 'desc("ROOT")' 0 files updated, 0 files merged, 1 files removed, 0 files unresolved - $ hg pull --confirm --config ui.interactive=True << EOF + $ hg pull --debug --confirm --config ui.interactive=True << EOF > n > EOF pulling from $TESTTMP/distributed-chain-building/server + query 1; heads searching for changes + taking quick initial sample + query 2; still undecided: 1, sample size is: 1 + 2 total queries in *.*s (glob) + 1 changesets found + list of changesets: + 391a2bf12b1b8b05a72400ae36b26d50a091dc22 + listing keys for "bookmarks" + bundle2-output-bundle: "HG20", 5 parts total + bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload + bundle2-output-part: "listkeys" (params: 1 mandatory) empty payload + bundle2-output-part: "obsmarkers" streamed payload + bundle2-output-part: "phase-heads" 48 bytes payload + bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload + bundle2-input-bundle: with-transaction + bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported adding changesets + add changeset 391a2bf12b1b adding manifests adding file changes + adding c_B1 revisions + bundle2-input-part: total payload size 485 + bundle2-input-part: "listkeys" (params: 1 mandatory) supported + bundle2-input-part: "obsmarkers" supported + bundle2-input-part: total payload size 143 + bundle2-input-part: "phase-heads" supported + bundle2-input-part: total payload size 48 + bundle2-input-part: "cache:rev-branch-cache" (advisory) supported + bundle2-input-part: total payload size 39 + bundle2-input-bundle: 5 parts total + checking for updated bookmarks adding 1 changesets with 1 changes to 1 files (+1 heads) 1 new obsolescence markers obsoleting 1 changesets
--- a/tests/test-obsolete.t Thu Dec 17 09:35:07 2020 -0800 +++ b/tests/test-obsolete.t Fri Apr 24 16:36:04 2020 +0200 @@ -1682,6 +1682,24 @@ | @ 0:a78f55e5508c (draft) [ ] 0 + + +Test that bundles can ship the markers without making them mandatory +for non-obsmarker enabled clients: + + $ hg --config experimental.evolution.bundle-obsmarker=1 --config experimental.evolution.bundle-obsmarker:mandatory=0 bundle --base 0 -r 1:: obslog-bundle.hg + 2 changesets found + $ hg debugbundle obslog-bundle.hg + Stream params: {Compression: BZ} + changegroup -- {nbchanges: 2, version: 02} (mandatory: True) + e016b03fd86fcccc54817d120b90b751aaf367d6 + b0551702f918510f01ae838ab03a463054c67b46 + cache:rev-branch-cache -- {} (mandatory: False) + obsmarkers -- {} (mandatory: False) + version: 1 (92 bytes) + e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'} + + Test that 'hg debugobsolete --index --rev' can show indices of obsmarkers when only a subset of those are displayed (because of --rev option) $ hg init doindexrev