##// END OF EJS Templates
bundle2: safely read unpack data from part header...
Pierre-Yves David -
r20887:662b79be default
parent child Browse files
Show More
@@ -292,16 +292,22 b' class unbundle20(object):'
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
General Comments 0
You need to be logged in to leave comments. Login now