changeset 21144:7a20fe8dc080

bundle2: use HG2X in the header The current implementation of bundle2 is still very experimental and the 3.0 freeze is yesterday. The current bundle2 format has never been field-tested, so we rename the header to HG2X. This leaves the HG20 header available for real usage as a stable format in Mercurial 3.1. We won't guarantee that future mercurial versions will keep supporting this `HG2X` format.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Apr 2014 15:27:54 -0400
parents 5bb5d4ba14e5
children 0c5088be66af
files mercurial/bundle2.py mercurial/exchange.py mercurial/localrepo.py mercurial/wireproto.py tests/test-bundle2.t
diffstat 5 files changed, 25 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Thu Apr 17 02:01:38 2014 -0400
+++ b/mercurial/bundle2.py	Thu Apr 17 15:27:54 2014 -0400
@@ -151,7 +151,7 @@
 _pack = struct.pack
 _unpack = struct.unpack
 
-_magicstring = 'HG20'
+_magicstring = 'HG2X'
 
 _fstreamparamsize = '>H'
 _fpartheadersize = '>H'
@@ -456,7 +456,7 @@
             magic, version = header[0:2], header[2:4]
             if magic != 'HG':
                 raise util.Abort(_('not a Mercurial bundle'))
-            if version != '20':
+            if version != '2X':
                 raise util.Abort(_('unknown bundle version %s') % version)
         self.ui.debug('start processing of %s stream\n' % header)
 
--- a/mercurial/exchange.py	Thu Apr 17 02:01:38 2014 -0400
+++ b/mercurial/exchange.py	Thu Apr 17 15:27:54 2014 -0400
@@ -32,7 +32,7 @@
         if alg is None:
             alg = changegroup.readexactly(fh, 2)
         return changegroup.unbundle10(fh, alg)
-    elif version == '20':
+    elif version == '2X':
         return bundle2.unbundle20(ui, fh, header=magic + version)
     else:
         raise util.Abort(_('%s: unknown bundle version %s') % (fname, version))
@@ -545,7 +545,7 @@
     """pull data using bundle2
 
     For now, the only supported data are changegroup."""
-    kwargs = {'bundlecaps': set(['HG20'])}
+    kwargs = {'bundlecaps': set(['HG2X'])}
     capsblob = bundle2.encodecaps(pullop.repo.bundle2caps)
     kwargs['bundlecaps'].add('bundle2=' + urllib.quote(capsblob))
     # pulling changegroup
@@ -644,7 +644,7 @@
 def getbundle(repo, source, heads=None, common=None, bundlecaps=None):
     """return a full bundle (with potentially multiple kind of parts)
 
-    Could be a bundle HG10 or a bundle HG20 depending on bundlecaps
+    Could be a bundle HG10 or a bundle HG2X depending on bundlecaps
     passed. For now, the bundle can contain only changegroup, but this will
     changes when more part type will be available for bundle2.
 
@@ -658,7 +658,7 @@
     # build bundle here.
     cg = changegroup.getbundle(repo, source, heads=heads,
                                common=common, bundlecaps=bundlecaps)
-    if bundlecaps is None or 'HG20' not in bundlecaps:
+    if bundlecaps is None or 'HG2X' not in bundlecaps:
         return cg
     # very crude first implementation,
     # the bundle API will change and the generation will be done lazily.
--- a/mercurial/localrepo.py	Thu Apr 17 02:01:38 2014 -0400
+++ b/mercurial/localrepo.py	Thu Apr 17 15:27:54 2014 -0400
@@ -109,7 +109,7 @@
                   format='HG10'):
         cg = exchange.getbundle(self._repo, source, heads=heads,
                                 common=common, bundlecaps=bundlecaps)
-        if bundlecaps is not None and 'HG20' in bundlecaps:
+        if bundlecaps is not None and 'HG2X' in bundlecaps:
             # When requesting a bundle2, getbundle returns a stream to make the
             # wire level function happier. We need to build a proper object
             # from it in local peer.
@@ -180,7 +180,7 @@
     requirements = ['revlogv1']
     filtername = None
 
-    bundle2caps = {'HG20': ()}
+    bundle2caps = {'HG2X': ()}
 
     # a list of (ui, featureset) functions.
     # only functions defined in module of enabled extensions are invoked
--- a/mercurial/wireproto.py	Thu Apr 17 02:01:38 2014 -0400
+++ b/mercurial/wireproto.py	Thu Apr 17 15:27:54 2014 -0400
@@ -335,7 +335,7 @@
         if bundlecaps is not None:
             opts['bundlecaps'] = ','.join(bundlecaps)
         f = self._callcompressable("getbundle", **opts)
-        if bundlecaps is not None and 'HG20' in bundlecaps:
+        if bundlecaps is not None and 'HG2X' in bundlecaps:
             return bundle2.unbundle20(self.ui, f)
         else:
             return changegroupmod.unbundle10(f, 'UN')
--- a/tests/test-bundle2.t	Thu Apr 17 02:01:38 2014 -0400
+++ b/tests/test-bundle2.t	Thu Apr 17 15:27:54 2014 -0400
@@ -201,7 +201,7 @@
 Test bundling
 
   $ hg bundle2
-  HG20\x00\x00\x00\x00 (no-eol) (esc)
+  HG2X\x00\x00\x00\x00 (no-eol) (esc)
 
 Test unbundling
 
@@ -231,7 +231,7 @@
 Test generation simple option
 
   $ hg bundle2 --param 'caution'
-  HG20\x00\x07caution\x00\x00 (no-eol) (esc)
+  HG2X\x00\x07caution\x00\x00 (no-eol) (esc)
 
 Test unbundling
 
@@ -243,7 +243,7 @@
 Test generation multiple option
 
   $ hg bundle2 --param 'caution' --param 'meal'
-  HG20\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
+  HG2X\x00\x0ccaution meal\x00\x00 (no-eol) (esc)
 
 Test unbundling
 
@@ -259,7 +259,7 @@
 Test generation
 
   $ hg bundle2 --param 'caution' --param 'meal=vegan' --param 'elephants'
-  HG20\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
+  HG2X\x00\x1ccaution meal=vegan elephants\x00\x00 (no-eol) (esc)
 
 Test unbundling
 
@@ -277,7 +277,7 @@
 Test generation
 
   $ hg bundle2 --param 'e|! 7/=babar%#==tutu' --param simple
-  HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
+  HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
 
 Test unbundling
 
@@ -301,7 +301,7 @@
 bundling debug
 
   $ hg bundle2 --debug --param 'e|! 7/=babar%#==tutu' --param simple ../out.hg2
-  start emission of HG20 stream
+  start emission of HG2X stream
   bundle parameter: e%7C%21%207/=babar%25%23%3D%3Dtutu simple
   start of parts
   end of bundle
@@ -309,12 +309,12 @@
 file content is ok
 
   $ cat ../out.hg2
-  HG20\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
+  HG2X\x00)e%7C%21%207/=babar%25%23%3D%3Dtutu simple\x00\x00 (no-eol) (esc)
 
 unbundling debug
 
   $ hg statbundle2 --debug < ../out.hg2
-  start processing of HG20 stream
+  start processing of HG2X stream
   reading bundle2 stream parameters
   ignoring unknown parameter 'e|! 7/'
   ignoring unknown parameter 'simple'
@@ -348,7 +348,7 @@
 =================
 
   $ hg bundle2 --parts ../parts.hg2 --debug
-  start emission of HG20 stream
+  start emission of HG2X stream
   bundle parameter: 
   start of parts
   bundle part: "test:empty"
@@ -360,7 +360,7 @@
   end of bundle
 
   $ cat ../parts.hg2
-  HG20\x00\x00\x00\x11 (esc)
+  HG2X\x00\x00\x00\x11 (esc)
   test:empty\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x11 (esc)
   test:empty\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x10	test:song\x00\x00\x00\x02\x00\x00\x00\x00\x00\xb2Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko (esc)
   Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
@@ -396,7 +396,7 @@
   parts count:   6
 
   $ hg statbundle2 --debug < ../parts.hg2
-  start processing of HG20 stream
+  start processing of HG2X stream
   reading bundle2 stream parameters
   options count: 0
   start extraction of bundle2 parts
@@ -466,7 +466,7 @@
 Process the bundle
 
   $ hg unbundle2 --debug < ../parts.hg2
-  start processing of HG20 stream
+  start processing of HG2X stream
   reading bundle2 stream parameters
   start extraction of bundle2 parts
   part header size: 17
@@ -543,7 +543,7 @@
 The reply is a bundle
 
   $ cat ../reply.hg2
-  HG20\x00\x00\x00\x1b\x06output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc)
+  HG2X\x00\x00\x00\x1b\x06output\x00\x00\x00\x00\x00\x01\x0b\x01in-reply-to3\x00\x00\x00\xd9The choir starts singing: (esc)
       Patali Dirapata, Cromda Cromda Ripalo, Pata Pata, Ko Ko Ko
       Bokoro Dipoulito, Rondi Rondi Pepino, Pata Pata, Ko Ko Ko
       Emana Karassoli, Loucra Loucra Ponponto, Pata Pata, Ko Ko Ko.
@@ -669,7 +669,7 @@
   9520eea781bcca16c1e15acc0ba14335a0e8e5ba
   eea13746799a9e0bfd88f29d3c2e9dc9389f524f
   02de42196ebee42ef284b6780a87cdc96e8eaab6
-  start emission of HG20 stream
+  start emission of HG2X stream
   bundle parameter: 
   start of parts
   bundle part: "changegroup"
@@ -687,7 +687,7 @@
   end of bundle
 
   $ cat ../rev.hg2
-  HG20\x00\x00\x00\x12\x0bchangegroup\x00\x00\x00\x00\x00\x00\x00\x00\x06\x13\x00\x00\x00\xa42\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j_\xdd\xd9\x89W\xc8\xa5JMCm\xfe\x1d\xa9\xd8\x7f!\xa1\xb9{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c (esc)
+  HG2X\x00\x00\x00\x12\x0bchangegroup\x00\x00\x00\x00\x00\x00\x00\x00\x06\x13\x00\x00\x00\xa42\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j_\xdd\xd9\x89W\xc8\xa5JMCm\xfe\x1d\xa9\xd8\x7f!\xa1\xb9{\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002\xafv\x86\xd4\x03\xcfE\xb5\xd9_-p\xce\xbe\xa5\x87\xac\x80j\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)6e1f4c47ecb533ffd0c8e52cdc88afb6cd39e20c (esc)
   \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02D (esc)
   \x00\x00\x00i\x00\x00\x00j\x00\x00\x00\x01D\x00\x00\x00\xa4\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\xcd\x01\x0b\x8c\xd9\x98\xf3\x98\x1aZ\x81\x15\xf9O\x8d\xa4\xabP`\x89\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95 \xee\xa7\x81\xbc\xca\x16\xc1\xe1Z\xcc\x0b\xa1C5\xa0\xe8\xe5\xba\x00\x00\x00\x00\x00\x00\x00)\x00\x00\x00)4dece9c826f69490507b98c6383a3009b295837d (esc)
   \x00\x00\x00f\x00\x00\x00h\x00\x00\x00\x02E (esc)
@@ -726,7 +726,7 @@
   addchangegroup return: 1
 
   $ cat ../rev-reply.hg2
-  HG20\x00\x00\x00/\x11reply:changegroup\x00\x00\x00\x00\x00\x02\x0b\x01\x06\x01in-reply-to1return1\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to1\x00\x00\x00dadding changesets (esc)
+  HG2X\x00\x00\x00/\x11reply:changegroup\x00\x00\x00\x00\x00\x02\x0b\x01\x06\x01in-reply-to1return1\x00\x00\x00\x00\x00\x1b\x06output\x00\x00\x00\x01\x00\x01\x0b\x01in-reply-to1\x00\x00\x00dadding changesets (esc)
   adding manifests
   adding file changes
   added 0 changesets with 0 changes to 3 files