Submitter | Pierre-Yves David |
---|---|
Date | April 7, 2015, 9:09 p.m. |
Message ID | <877b5ed6bd636447ef87.1428440981@marginatus.alto.octopoid.net> |
Download | mbox | patch |
Permalink | /patch/8550/ |
State | Accepted |
Headers | show |
Comments
On Tue, Apr 7, 2015 at 2:11 PM Pierre-Yves David < pierre-yves.david@ens-lyon.org> wrote: > # HG changeset patch > # User Pierre-Yves David <pierre-yves.david@fb.com> > # Date 1428367164 25200 > # Mon Apr 06 17:39:24 2015 -0700 > # Node ID 877b5ed6bd636447ef8701b36e73d5e2b356e9b2 > # Parent e176f57dbf891662f7e63773d7f186772162ad80 > bundle2: detect bundle2 stream/request on /HG2./ instead of /HG20/ > I'm changing HG20 to HG2Y in flight. > > To support more bundle2 formats, we need a wider detection of > bundle2-family > stream. The various place what were explicitly detecting the full magic > string > are now matching on the first three characters of it. > > diff --git a/mercurial/exchange.py b/mercurial/exchange.py > --- a/mercurial/exchange.py > +++ b/mercurial/exchange.py > @@ -30,11 +30,11 @@ def readbundle(ui, fh, fname, vfs=None): > raise util.Abort(_('%s: not a Mercurial bundle') % fname) > if version == '10': > if alg is None: > alg = changegroup.readexactly(fh, 2) > return changegroup.cg1unpacker(fh, alg) > - elif version == '2Y': > + elif version.startswith('2'): > return bundle2.getunbundler(ui, fh, header=magic + version) > else: > raise util.Abort(_('%s: unknown bundle version %s') % (fname, > version)) > > def buildobsmarkerspart(bundler, markers): > @@ -1166,11 +1166,17 @@ def getbundle(repo, source, heads=None, > > The implementation is at a very early stage and will get massive > rework > when the API of bundle is refined. > """ > # bundle10 case > - if bundlecaps is None or 'HG2Y' not in bundlecaps: > + usebundle2 = False > + if bundlecaps is not None: > + for cap in bundlecaps: > + if cap.startswith('HG2'): > + usebundle2 = True > + break > I'm changing this to: usebundle2 = util.any((cap.startswith('HG2') for cap in bundlecaps)) > + if not usebundle2: > if bundlecaps and not kwargs.get('cg', True): > raise ValueError(_('request for bundle10 must include > changegroup')) > > if kwargs: > raise ValueError(_('unsupported getbundle arguments: %s') > diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py > --- a/mercurial/wireproto.py > +++ b/mercurial/wireproto.py > @@ -361,12 +361,15 @@ class wirepeer(peer.peerrepository): > raise KeyError('unknown getbundle option type %s' > % keytype) > opts[key] = value > f = self._callcompressable("getbundle", **opts) > bundlecaps = kwargs.get('bundlecaps') > - if bundlecaps is not None and 'HG2Y' in bundlecaps: > - return bundle2.getunbundler(self.ui, f) > + if bundlecaps is None: > + bundlecaps = () # kwargs could have it to None > + for cap in bundlecaps: > + if cap.startswith('HG2'): > I'm changing this to: if util.any((cap.startswith('HG2') for cap in bundlecaps)): + return bundle2.getunbundler(self.ui, f) > > else: > return changegroupmod.cg1unpacker(f, 'UN') > > def unbundle(self, cg, heads, source): > '''Send cg (a readable file-like object representing the > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel >
Patch
diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -30,11 +30,11 @@ def readbundle(ui, fh, fname, vfs=None): raise util.Abort(_('%s: not a Mercurial bundle') % fname) if version == '10': if alg is None: alg = changegroup.readexactly(fh, 2) return changegroup.cg1unpacker(fh, alg) - elif version == '2Y': + elif version.startswith('2'): return bundle2.getunbundler(ui, fh, header=magic + version) else: raise util.Abort(_('%s: unknown bundle version %s') % (fname, version)) def buildobsmarkerspart(bundler, markers): @@ -1166,11 +1166,17 @@ def getbundle(repo, source, heads=None, The implementation is at a very early stage and will get massive rework when the API of bundle is refined. """ # bundle10 case - if bundlecaps is None or 'HG2Y' not in bundlecaps: + usebundle2 = False + if bundlecaps is not None: + for cap in bundlecaps: + if cap.startswith('HG2'): + usebundle2 = True + break + if not usebundle2: if bundlecaps and not kwargs.get('cg', True): raise ValueError(_('request for bundle10 must include changegroup')) if kwargs: raise ValueError(_('unsupported getbundle arguments: %s') diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -361,12 +361,15 @@ class wirepeer(peer.peerrepository): raise KeyError('unknown getbundle option type %s' % keytype) opts[key] = value f = self._callcompressable("getbundle", **opts) bundlecaps = kwargs.get('bundlecaps') - if bundlecaps is not None and 'HG2Y' in bundlecaps: - return bundle2.getunbundler(self.ui, f) + if bundlecaps is None: + bundlecaps = () # kwargs could have it to None + for cap in bundlecaps: + if cap.startswith('HG2'): + return bundle2.getunbundler(self.ui, f) else: return changegroupmod.cg1unpacker(f, 'UN') def unbundle(self, cg, heads, source): '''Send cg (a readable file-like object representing the