Esempio n. 1
0
def get_num_tree(prefix_bytes):
  """Return a dictionary of the blob contents specified by |prefix_bytes|.
  This is in the form of {<full ref>: <gen num> ...}

  >>> get_num_tree('\x83\xb4')
  {'\x83\xb4\xe3\xe4W\xf9J*\x8f/c\x16\xecD\xd1\x04\x8b\xa9qz': 169, ...}
  """
  ret = {}
  ref = '%s:%s' % (REF, pathlify(prefix_bytes))

  p = subprocess.Popen(['git', 'cat-file', 'blob', ref],
                        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  p.stderr.close()
  raw = buffer(p.stdout.read())
  for i in xrange(len(raw) / CHUNK_SIZE):
    ref, num = struct.unpack_from(CHUNK_FMT, raw, i * CHUNK_SIZE)
    ret[ref] = num

  return ret
Esempio n. 2
0
def leaf_map_fn(prefix_tree):
  pre, tree = prefix_tree
  return UPDATE_IDX_FMT % (intern_num_tree(tree), pathlify(pre))