changeset 32549:37d70ba1d9d1

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 28 May 2017 11:50:43 -0700
parents e70d6dbde713
children b62b2b373bce
files mercurial/bundle2.py mercurial/commands.py tests/test-obsolete-changeset-exchange.t
diffstat 3 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Sun May 28 11:48:18 2017 -0700
+++ b/mercurial/bundle2.py	Sun May 28 11:50:43 2017 -0700
@@ -1348,7 +1348,10 @@
     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 @@
 
     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)
--- a/mercurial/commands.py	Sun May 28 11:48:18 2017 -0700
+++ b/mercurial/commands.py	Sun May 28 11:50:43 2017 -0700
@@ -1326,6 +1326,8 @@
 
 
     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)
--- a/tests/test-obsolete-changeset-exchange.t	Sun May 28 11:48:18 2017 -0700
+++ b/tests/test-obsolete-changeset-exchange.t	Sun May 28 11:50:43 2017 -0700
@@ -83,6 +83,21 @@
   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)