bundlespec: handle the presence of obsmarker part
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 25 May 2022 11:53:34 +0200
changeset 49335 04cdb442a892
parent 49334 6d15a8971e30
child 49336 290c29df1915
bundlespec: handle the presence of obsmarker part This make `hg debugbundle --spec` more informative about extra part in the bundle.
mercurial/exchange.py
tests/test-obsolete-bundle-strip.t
--- a/mercurial/exchange.py	Wed May 18 12:07:50 2022 +0100
+++ b/mercurial/exchange.py	Wed May 25 11:53:34 2022 +0200
@@ -146,6 +146,10 @@
                 splitted = requirements.split()
                 params = bundle2._formatrequirementsparams(splitted)
                 return b'none-v2;stream=v2;%s' % params
+            elif part.type == b'obsmarkers':
+                params[b'obsolescence'] = b'yes'
+                if not part.mandatory:
+                    params[b'obsolescence-mandatory'] = b'no'
 
         if not version:
             raise error.Abort(
--- a/tests/test-obsolete-bundle-strip.t	Wed May 18 12:07:50 2022 +0100
+++ b/tests/test-obsolete-bundle-strip.t	Wed May 25 11:53:34 2022 +0200
@@ -1489,6 +1489,8 @@
 
   $ hg bundle -R repo-with-obs --type 'v2;obsolescence=yes' --all --hidden bundle-type-with-obs
   1 changesets found
+  $ hg debugbundle --spec bundle-type-with-obs
+  bzip2-v2;obsolescence=yes
   $ hg debugbundle bundle-type-with-obs --part-type obsmarkers
   Stream params: {Compression: BZ}
   obsmarkers -- {} (mandatory: True)
@@ -1497,6 +1499,8 @@
 
   $ hg bundle -R repo-with-obs --type 'v2;obsolescence=yes;obsolescence-mandatory=no' --all --hidden bundle-type-with-obs-adv
   1 changesets found
+  $ hg debugbundle --spec bundle-type-with-obs-adv
+  bzip2-v2;obsolescence=yes;obsolescence-mandatory=no
   $ hg debugbundle bundle-type-with-obs-adv --part-type obsmarkers
   Stream params: {Compression: BZ}
   obsmarkers -- {} (mandatory: False)
@@ -1504,6 +1508,8 @@
       1ea73414a91b0920940797d8fc6a11e447f8ea1e 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
   $ hg bundle -R repo-with-obs --type 'v2;obsolescence=no' --all --hidden bundle-type-without-obs
   1 changesets found
+  $ hg debugbundle --spec bundle-type-without-obs
+  bzip2-v2
   $ hg debugbundle bundle-type-without-obs --part-type obsmarkers
   Stream params: {Compression: BZ}
 
@@ -1512,6 +1518,8 @@
 
   $ hg bundle -R repo-with-obs --config experimental.evolution.bundle-obsmarker=false --type 'v2;obsolescence=yes' --all --hidden bundle-type-with-obs2
   1 changesets found
+  $ hg debugbundle --spec bundle-type-with-obs2
+  bzip2-v2;obsolescence=yes
   $ hg debugbundle bundle-type-with-obs2 --part-type obsmarkers
   Stream params: {Compression: BZ}
   obsmarkers -- {} (mandatory: True)
@@ -1519,5 +1527,7 @@
       1ea73414a91b0920940797d8fc6a11e447f8ea1e 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
   $ hg bundle -R repo-with-obs --config experimental.evolution.bundle-obsmarker=true --type 'v2;obsolescence=no' --all --hidden bundle-type-without-obs2
   1 changesets found
+  $ hg debugbundle --spec bundle-type-without-obs2
+  bzip2-v2
   $ hg debugbundle bundle-type-without-obs2 --part-type obsmarkers
   Stream params: {Compression: BZ}