mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
unbundle20: allow generic dispatch between unbundlers
We now take full advantage of the 'getunbundler' function by using a '{version -> unbundler-class}' mapping. This map currently contains a single entry but will make it easy to support more versions from an extension/the future. At some point, this map will probably contain bundler-class information too, in the same fashion the packer map does. However, this is not critically required right now so it will happen by itself when needed. The main target is to allow HG2Y support in an extension to ease transition of companies using the experimental protocol in production (yeah...) But I've no doubt this will be useful when playing with a future HG21.
This commit is contained in:
parent
d67091a36f
commit
f96ca2174a
@ -525,12 +525,13 @@ def getunbundler(ui, fp, header=None):
|
||||
"""return a valid unbundler object for a given header"""
|
||||
if header is None:
|
||||
header = changegroup.readexactly(fp, 4)
|
||||
magic, version = header[0:2], header[2:4]
|
||||
if magic != 'HG':
|
||||
raise util.Abort(_('not a Mercurial bundle'))
|
||||
if version != '2Y':
|
||||
raise util.Abort(_('unknown bundle version %s') % version)
|
||||
unbundler = unbundle20(ui, fp)
|
||||
magic, version = header[0:2], header[2:4]
|
||||
if magic != 'HG':
|
||||
raise util.Abort(_('not a Mercurial bundle'))
|
||||
unbundlerclass = formatmap.get(version)
|
||||
if unbundlerclass is None:
|
||||
raise util.Abort(_('unknown bundle version %s') % version)
|
||||
unbundler = unbundlerclass(ui, fp)
|
||||
ui.debug('start processing of %s stream\n' % header)
|
||||
return unbundler
|
||||
|
||||
@ -615,6 +616,8 @@ class unbundle20(unpackermixin):
|
||||
def compressed(self):
|
||||
return False
|
||||
|
||||
formatmap = {'2Y': unbundle20}
|
||||
|
||||
class bundlepart(object):
|
||||
"""A bundle2 part contains application level payload
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user