mercurial/bundle2.py
changeset 24648 5cac3accdaa1
parent 24642 54e5c239c2d9
child 24686 e0e28e910fa3
equal deleted inserted replaced
24647:fb446c57f8f9 24648:5cac3accdaa1
   523 
   523 
   524 def getunbundler(ui, fp, header=None):
   524 def getunbundler(ui, fp, header=None):
   525     """return a valid unbundler object for a given header"""
   525     """return a valid unbundler object for a given header"""
   526     if header is None:
   526     if header is None:
   527         header = changegroup.readexactly(fp, 4)
   527         header = changegroup.readexactly(fp, 4)
   528         magic, version = header[0:2], header[2:4]
   528     magic, version = header[0:2], header[2:4]
   529         if magic != 'HG':
   529     if magic != 'HG':
   530             raise util.Abort(_('not a Mercurial bundle'))
   530         raise util.Abort(_('not a Mercurial bundle'))
   531         if version != '2Y':
   531     unbundlerclass = formatmap.get(version)
   532             raise util.Abort(_('unknown bundle version %s') % version)
   532     if unbundlerclass is None:
   533     unbundler = unbundle20(ui, fp)
   533         raise util.Abort(_('unknown bundle version %s') % version)
       
   534     unbundler = unbundlerclass(ui, fp)
   534     ui.debug('start processing of %s stream\n' % header)
   535     ui.debug('start processing of %s stream\n' % header)
   535     return unbundler
   536     return unbundler
   536 
   537 
   537 class unbundle20(unpackermixin):
   538 class unbundle20(unpackermixin):
   538     """interpret a bundle2 stream
   539     """interpret a bundle2 stream
   612             return self._readexact(headersize)
   613             return self._readexact(headersize)
   613         return None
   614         return None
   614 
   615 
   615     def compressed(self):
   616     def compressed(self):
   616         return False
   617         return False
       
   618 
       
   619 formatmap = {'2Y': unbundle20}
   617 
   620 
   618 class bundlepart(object):
   621 class bundlepart(object):
   619     """A bundle2 part contains application level payload
   622     """A bundle2 part contains application level payload
   620 
   623 
   621     The part `type` is used to route the part to the application level
   624     The part `type` is used to route the part to the application level