# HG changeset patch # User Pierre-Yves David # Date 2017-05-28 18:50:43 # Node ID 37d70ba1d9d1e7c6416b7c2f20e7f8a4824bd2a6 # Parent e70d6dbde71324f9393a564dc28f3a80611cdf7d bundle: add an experimental knob to include obsmarkers in bundle The "hg bundle" command is a good place to test if the inclusion of obsmarkers within a bundle is working well (part exists, content is correct etc). So we add a way to have them included. Ideally, this would be controlled by a change around bundlespec (bundlespec "v3" + arguments). However, my main goal is to have obsmarkers included in bundle created by the 'hg strip' command, not the 'hg bundle' so for now I'm avoiding the detour through bundlespec rework territory. Better debug output for obsmarkers in 'debugbundle' will be added in later changesets. The 'test-obsolete-bundle-strip.t' test will also get updated in a later changeset to keep the current changeset smaller. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1348,7 +1348,10 @@ def writenewbundle(ui, repo, source, fil elif not bundletype.startswith('HG20'): raise error.ProgrammingError('unknown bundle type: %s' % bundletype) - bundle = bundle20(ui) + caps = {} + if 'obsolescence' in opts: + caps['obsmarkers'] = ('V1',) + bundle = bundle20(ui, caps) bundle.setcompression(compression, compopts) _addpartsfromopts(ui, repo, bundle, source, outgoing, opts) chunkiter = bundle.getchunks() @@ -1377,6 +1380,10 @@ def _addpartsfromopts(ui, repo, bundler, addparttagsfnodescache(repo, bundler, outgoing) + if opts.get('obsolescence', False): + obsmarkers = repo.obsstore.relevantmarkers(outgoing.missing) + buildobsmarkerspart(bundler, obsmarkers) + def addparttagsfnodescache(repo, bundler, outgoing): # we include the tags fnode cache for the bundle changeset # (as an optional parts) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1326,6 +1326,8 @@ def bundle(ui, repo, fname, dest=None, * contentopts = {'cg.version': cgversion} + if repo.ui.configbool('experimental', 'evolution.bundle-obsmarker', False): + contentopts['obsolescence'] = True bundle2.writenewbundle(ui, repo, 'bundle', fname, bversion, outgoing, contentopts, compression=bcompression, compopts=compopts) diff --git a/tests/test-obsolete-changeset-exchange.t b/tests/test-obsolete-changeset-exchange.t --- a/tests/test-obsolete-changeset-exchange.t +++ b/tests/test-obsolete-changeset-exchange.t @@ -83,6 +83,21 @@ check that bundle is not affected adding file changes added 1 changesets with 0 changes to 1 files (+1 heads) (run 'hg heads' to see heads) + +check-that bundle can contain markers: + + $ hg bundle --hidden --rev f89bcc95eba5 --base "f89bcc95eba5^" ../f89bcc95eba5-obs.hg --config experimental.evolution.bundle-obsmarker=1 + 1 changesets found + $ hg debugbundle ../f89bcc95eba5.hg + Stream params: sortdict([('Compression', 'BZ')]) + changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])" + f89bcc95eba5174b1ccc3e33a82e84c96e8338ee + $ hg debugbundle ../f89bcc95eba5-obs.hg + Stream params: sortdict([('Compression', 'BZ')]) + changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])" + f89bcc95eba5174b1ccc3e33a82e84c96e8338ee + obsmarkers -- 'sortdict()' + $ cd .. pull does not fetch excessive changesets when common node is hidden (issue4982)