mercurial/bundle2.py
changeset 20887 662b79be093c
parent 20877 9e9e3a4e9261
child 20889 deed5edb72de
equal deleted inserted replaced
20886:203908968644 20887:662b79be093c
   290             """return the next <size> byte from the header"""
   290             """return the next <size> byte from the header"""
   291             offset = self._offset
   291             offset = self._offset
   292             data = headerblock[offset:(offset + size)]
   292             data = headerblock[offset:(offset + size)]
   293             self._offset = offset + size
   293             self._offset = offset + size
   294             return data
   294             return data
   295         typesize = _unpack(_fparttypesize, fromheader(1))[0]
   295         def unpackheader(format):
       
   296             """read given format from header
       
   297 
       
   298             This automatically compute the size of the format to read."""
       
   299             data = fromheader(struct.calcsize(format))
       
   300             return _unpack(format, data)
       
   301 
       
   302         typesize = unpackheader(_fparttypesize)[0]
   296         parttype = fromheader(typesize)
   303         parttype = fromheader(typesize)
   297         self.ui.debug('part type: "%s"\n' % parttype)
   304         self.ui.debug('part type: "%s"\n' % parttype)
   298         ## reading parameters
   305         ## reading parameters
   299         # param count
   306         # param count
   300         mancount, advcount = _unpack(_fpartparamcount, fromheader(2))
   307         mancount, advcount = unpackheader(_fpartparamcount)
   301         self.ui.debug('part parameters: %i\n' % (mancount + advcount))
   308         self.ui.debug('part parameters: %i\n' % (mancount + advcount))
   302         # param size
   309         # param size
   303         paramsizes = _unpack(_makefpartparamsizes(mancount + advcount),
   310         paramsizes = unpackheader(_makefpartparamsizes(mancount + advcount))
   304                              fromheader(2*(mancount + advcount)))
       
   305         # make it a list of couple again
   311         # make it a list of couple again
   306         paramsizes = zip(paramsizes[::2], paramsizes[1::2])
   312         paramsizes = zip(paramsizes[::2], paramsizes[1::2])
   307         # split mandatory from advisory
   313         # split mandatory from advisory
   308         mansizes = paramsizes[:mancount]
   314         mansizes = paramsizes[:mancount]
   309         advsizes = paramsizes[mancount:]
   315         advsizes = paramsizes[mancount:]