bundle-spec: add an official method to format a spec into a string
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 21 Jun 2023 15:53:33 +0200
changeset 50712 0913a49e020c
parent 50711 40638610c6ee
child 50713 ddc55fb220ba
bundle-spec: add an official method to format a spec into a string This will be useful for automatic-clonebundles.
mercurial/bundlecaches.py
--- a/mercurial/bundlecaches.py	Mon Jun 19 18:15:35 2023 +0200
+++ b/mercurial/bundlecaches.py	Wed Jun 21 15:53:33 2023 +0200
@@ -89,6 +89,12 @@
         if overwrite or key not in self._explicit_params:
             self._explicit_params[key] = value
 
+    def as_spec(self):
+        parts = [b"%s-%s" % (self.compression, self.version)]
+        for param in sorted(self._explicit_params.items()):
+            parts.append(b'%s=%s' % param)
+        return b';'.join(parts)
+
 
 # Maps bundle version human names to changegroup versions.
 _bundlespeccgversions = {