def unpack_patches(hg_unbundle10_obj, remaining):
 while (remaining >= 12):
  (start, end, blocklen) = struct.unpack('>lll', readexactly(hg_unbundle10_obj, 12))
  remaining -= 12
  if (blocklen > remaining):
   raise Exception('unexpected end of patch stream')
  block = readexactly(hg_unbundle10_obj, blocklen)
  remaining -= blocklen
  (yield {'start': start, 'end': end, 'blocklen': blocklen, 'block': block.encode('string_escape')})
 if (remaining > 0):
  log.error('Unexpected end of patch stream, %s remaining', remaining)
  raise Exception('unexpected end of patch stream')

def unpack_patches ( hg_unbundle10_obj , remaining ) : while ( remaining >= 12 ) : ( start , end , blocklen ) = struct . unpack ( '>lll' , readexactly ( hg_unbundle10_obj , 12 ) ) remaining -= 12 if ( blocklen > remaining ) : raise Exception ( 'unexpected end of patch stream' ) block = readexactly ( hg_unbundle10_obj , blocklen ) remaining -= blocklen ( yield { 'start' : start , 'end' : end , 'blocklen' : blocklen , 'block' : block . encode ( 'string_escape' ) } ) if ( remaining > 0 ) : log . error ( 'Unexpected end of patch stream, %s remaining' , remaining ) raise Exception ( 'unexpected end of patch stream' )
this method provides a generator of patches from the data field in a chunk .