def get_image_diff_json(image_id):
 diff_json = get_image_diff_cache(image_id)
 if diff_json:
  return diff_json
 ancestry_path = store.image_ancestry_path(image_id)
 ancestry = store.get_json(ancestry_path)[1:]
 files = json.loads(get_image_files_json(image_id))
 info_map = get_file_info_map(files)
 deleted = {}
 changed = {}
 created = {}
 for id in ancestry:
  ancestor_files = json.loads(get_image_files_json(id))
  ancestor_map = get_file_info_map(ancestor_files)
  for (filename, info) in info_map.items():
   ancestor_info = ancestor_map.get(filename)
   if info[1]:
    deleted[filename] = info
    del info_map[filename]
   elif ancestor_info:
    if ancestor_info[1]:
     created[filename] = info
    else:
     changed[filename] = info
    del info_map[filename]
 created.update(info_map)
 diff_json = json.dumps({'deleted': deleted, 'changed': changed, 'created': created})
 set_image_diff_cache(image_id, diff_json)
 return diff_json

def get_image_diff_json ( image_id ) : diff_json = get_image_diff_cache ( image_id ) if diff_json : return diff_json ancestry_path = store . image_ancestry_path ( image_id ) ancestry = store . get_json ( ancestry_path ) [ 1 : ] files = json . loads ( get_image_files_json ( image_id ) ) info_map = get_file_info_map ( files ) deleted = { } changed = { } created = { } for id in ancestry : ancestor_files = json . loads ( get_image_files_json ( id ) ) ancestor_map = get_file_info_map ( ancestor_files ) for ( filename , info ) in info_map . items ( ) : ancestor_info = ancestor_map . get ( filename ) if info [ 1 ] : deleted [ filename ] = info del info_map [ filename ] elif ancestor_info : if ancestor_info [ 1 ] : created [ filename ] = info else : changed [ filename ] = info del info_map [ filename ] created . update ( info_map ) diff_json = json . dumps ( { 'deleted' : deleted , 'changed' : changed , 'created' : created } ) set_image_diff_cache ( image_id , diff_json ) return diff_json
get json describing file differences in layer calculate the diff information for the files contained within the layer .