mercurial/bundle2.py
changeset 20889 deed5edb72de
parent 20887 662b79be093c
child 20890 ec7fc110faee
equal deleted inserted replaced
20888:0b0d3800c248 20889:deed5edb72de
   145 
   145 
   146     The number parameters is variable so we need to build that format
   146     The number parameters is variable so we need to build that format
   147     dynamically.
   147     dynamically.
   148     """
   148     """
   149     return '>'+('BB'*nbparams)
   149     return '>'+('BB'*nbparams)
       
   150 
       
   151 
       
   152 parthandlermapping = {}
       
   153 
       
   154 def processbundle(repo, stream):
       
   155     """This function process a bundle, apply effect to/from a repo
       
   156 
       
   157     Currently it:
       
   158     - parse a stream into an unbundle20 object
       
   159     - iterate over each parts then search and use the proper handling code to
       
   160       process the part.
       
   161 
       
   162     Parts are processes in order.
       
   163 
       
   164     This is very early version of this function that will be strongly reworked
       
   165     before final usage.
       
   166 
       
   167     All unknown parts are currently ignored (Mandatory parts logic will comes
       
   168     later).
       
   169     """
       
   170     ui = repo.ui
       
   171     # Extraction of the unbundler object will most likely change. It may be
       
   172     # done outside of this function, the unbundler would be passed as argument.
       
   173     # in all case the unbundler will eventually be created by a
       
   174     # `changegroup.readbundle` style function.
       
   175     unbundler = unbundle20(ui, stream)
       
   176     # todo:
       
   177     # - replace this is a init function soon.
       
   178     # - exception catching
       
   179     unbundler.params
       
   180     for part in unbundler:
       
   181         parttype = part.type
       
   182         # part key are matched lower case
       
   183         key = parttype.lower()
       
   184         try:
       
   185             handler = parthandlermapping[key]
       
   186             ui.debug('found an handler for part %r\n' % parttype)
       
   187         except KeyError:
       
   188             ui.debug('ignoring unknown advisory part %r\n' % key)
       
   189             # todo: consume the part (once we use streamed parts)
       
   190             continue
       
   191         handler(repo, part)
   150 
   192 
   151 class bundle20(object):
   193 class bundle20(object):
   152     """represent an outgoing bundle2 container
   194     """represent an outgoing bundle2 container
   153 
   195 
   154     Use the `addparam` method to add stream level parameter. and `addpart` to
   196     Use the `addparam` method to add stream level parameter. and `addpart` to