Mercurial > public > mercurial-scm > hg-stable
diff mercurial/exchange.py @ 23009:90f86ad3d4ff
bundle2: change header size and make them signed (new format)
We are changing all integers that denote the size of a chunk to read to int32.
There are two main motivations for that.
First, we change everything to the same width (32 bits) to make it possible for
a reasonably agnostic actor to forward a bundle2 without any extra processing.
With this change, this could be achieved by just reading int32s and forwarding
chunks of the size read. A bit a smartness would be logic to detect the end of
stream but nothing too complicated.
Second, we need some capacity to transmit special information during the bundle
processing. For example we would like to be able to raise an exception while a
part is being read if this exception happend while this part was generated.
Having signed integer let us use negative numbers to trigger special events
during the parsing of the bundle.
The format is renamed for B2X to B2Y because this breaks binary
compatibility. The B2X format support is dropped. It was experimental to
allow this kind of things. All elements not directly related to the binary
format remain flagged "b2x" because they are still compatible.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 01 Oct 2014 23:40:23 -0500 |
parents | 90c425f80316 |
children | e4aeb14248ca |
line wrap: on
line diff
--- a/mercurial/exchange.py Tue Oct 14 02:32:26 2014 -0700 +++ b/mercurial/exchange.py Wed Oct 01 23:40:23 2014 -0500 @@ -32,7 +32,7 @@ if alg is None: alg = changegroup.readexactly(fh, 2) return changegroup.cg1unpacker(fh, alg) - elif version == '2X': + elif version == '2Y': return bundle2.unbundle20(ui, fh, header=magic + version) else: raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) @@ -1099,7 +1099,7 @@ def caps20to10(repo): """return a set with appropriate options to use bundle20 during getbundle""" - caps = set(['HG2X']) + caps = set(['HG2Y']) capsblob = bundle2.encodecaps(bundle2.getrepocaps(repo)) caps.add('bundle2=' + urllib.quote(capsblob)) return caps @@ -1132,7 +1132,7 @@ **kwargs): """return a full bundle (with potentially multiple kind of parts) - Could be a bundle HG10 or a bundle HG2X depending on bundlecaps + Could be a bundle HG10 or a bundle HG2Y 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. @@ -1144,7 +1144,7 @@ when the API of bundle is refined. """ # bundle10 case - if bundlecaps is None or 'HG2X' not in bundlecaps: + if bundlecaps is None or 'HG2Y' not in bundlecaps: if bundlecaps and not kwargs.get('cg', True): raise ValueError(_('request for bundle10 must include changegroup'))