Пример #1
0
def main(argv):
    colorama.init()
    assert len(argv) == 1, "No arguments expected"
    branch_map = {}
    par_map = collections.defaultdict(list)
    for branch in branches():
        par = upstream(branch) or NO_UPSTREAM
        branch_map[branch] = par
        par_map[par].append(branch)

    current = current_branch()
    hashes = hash_multi(current, *branch_map.keys())
    current_hash = hashes[0]
    par_hashes = {
        k: hashes[i + 1]
        for i, k in enumerate(branch_map.iterkeys())
    }
    par_hashes[NO_UPSTREAM] = 0
    tag_set = tags()
    while par_map:
        for parent in par_map:
            if parent not in branch_map:
                if parent not in par_hashes:
                    par_hashes[parent] = hash_one(parent)
                print_branch(current, current_hash, parent, par_hashes,
                             par_map, branch_map, tag_set)
                break
Пример #2
0
def finalize(targets):
    """Saves all cache data to the git repository.

  After calculating the generation number for |targets|, call finalize() to
  save all the work to the git repository.

  This in particular saves the trees referred to by DIRTY_TREES.
  """
    if not DIRTY_TREES:
        return

    msg = 'git-number Added %s numbers' % sum(DIRTY_TREES.itervalues())

    idx = os.path.join(git.run('rev-parse', '--git-dir'), 'number.idx')
    env = os.environ.copy()
    env['GIT_INDEX_FILE'] = idx

    progress_message = 'Finalizing: (%%(count)d/%d)' % len(DIRTY_TREES)
    with git.ProgressPrinter(progress_message) as inc:
        git.run('read-tree', REF, env=env)

        prefixes_trees = ((p, get_number_tree(p)) for p in sorted(DIRTY_TREES))
        updater = subprocess2.Popen(
            ['git', 'update-index', '-z', '--index-info'],
            stdin=subprocess2.PIPE,
            env=env)

        with git.ScopedPool(kind=POOL_KIND) as leaf_pool:
            for item in leaf_pool.imap(leaf_map_fn, prefixes_trees):
                updater.stdin.write(item)
                inc()

        updater.stdin.close()
        updater.wait()
        assert updater.returncode == 0

        tree_id = git.run('write-tree', env=env)
        commit_cmd = [
            # Git user.name and/or user.email may not be configured, so specifying
            # them explicitly. They are not used, but requried by Git.
            '-c',
            'user.name=%s' % AUTHOR_NAME,
            '-c',
            'user.email=%s' % AUTHOR_EMAIL,
            'commit-tree',
            '-m',
            msg,
            '-p'
        ] + git.hash_multi(REF)
        for t in targets:
            commit_cmd.extend(['-p', binascii.hexlify(t)])
        commit_cmd.append(tree_id)
        commit_hash = git.run(*commit_cmd)
        git.run('update-ref', REF, commit_hash)
    DIRTY_TREES.clear()
Пример #3
0
def finalize(targets):
  """Saves all cache data to the git repository.

  After calculating the generation number for |targets|, call finalize() to
  save all the work to the git repository.

  This in particular saves the trees referred to by DIRTY_TREES.
  """
  if not DIRTY_TREES:
    return

  msg = 'git-number Added %s numbers' % sum(DIRTY_TREES.itervalues())

  idx = os.path.join(git.run('rev-parse', '--git-dir'), 'number.idx')
  env = os.environ.copy()
  env['GIT_INDEX_FILE'] = idx

  progress_message = 'Finalizing: (%%(count)d/%d)' % len(DIRTY_TREES)
  with git.ProgressPrinter(progress_message) as inc:
    git.run('read-tree', REF, env=env)

    prefixes_trees = ((p, get_number_tree(p)) for p in sorted(DIRTY_TREES))
    updater = subprocess2.Popen(['git', 'update-index', '-z', '--index-info'],
                                stdin=subprocess2.PIPE, env=env)

    with git.ScopedPool(kind=POOL_KIND) as leaf_pool:
      for item in leaf_pool.imap(leaf_map_fn, prefixes_trees):
        updater.stdin.write(item)
        inc()

    updater.stdin.close()
    updater.wait()
    assert updater.returncode == 0

    tree_id = git.run('write-tree', env=env)
    commit_cmd = [
        # Git user.name and/or user.email may not be configured, so specifying
        # them explicitly. They are not used, but requried by Git.
        '-c', 'user.name=%s' % AUTHOR_NAME,
        '-c', 'user.email=%s' % AUTHOR_EMAIL,
        'commit-tree',
        '-m', msg,
        '-p'] + git.hash_multi(REF)
    for t in targets:
      commit_cmd.extend(['-p', binascii.hexlify(t)])
    commit_cmd.append(tree_id)
    commit_hash = git.run(*commit_cmd)
    git.run('update-ref', REF, commit_hash)
  DIRTY_TREES.clear()
Пример #4
0
def main(argv):
  colorama.init()
  assert len(argv) == 1, "No arguments expected"
  branch_map = {}
  par_map = collections.defaultdict(list)
  for branch in branches():
    par = upstream(branch) or NO_UPSTREAM
    branch_map[branch] = par
    par_map[par].append(branch)

  current = current_branch()
  hashes = hash_multi(current, *branch_map.keys())
  current_hash = hashes[0]
  par_hashes = {k: hashes[i+1] for i, k in enumerate(branch_map.iterkeys())}
  par_hashes[NO_UPSTREAM] = 0
  tag_set = tags()
  while par_map:
    for parent in par_map:
      if parent not in branch_map:
        if parent not in par_hashes:
          par_hashes[parent] = hash_one(parent)
        print_branch(current, current_hash, parent, par_hashes, par_map,
                     branch_map, tag_set)
        break