Commit b56a43a9 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Read the git config only once when doing a git cl issue -r lookup

Running git cl issue -r in a tree with dozens/hundreds of branches
could be a bit slow since the code parsed .git/config twice per
local branch. By parsing it only once and then looking things up
in a hashtable it becomes much faster. (For my local tree with 700
branches 13 seconds became 0.3 seconds)

Bug: 880734
Change-Id: I67f45de32fb7f2cc5960174e59f3476ef3021a3a
Reviewed-on: https://chromium-review.googlesource.com/1206352
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
parent 1e591dca
......@@ -4608,9 +4608,20 @@ def CMDissue(parser, args):
'--format=%(refname)']).splitlines()
# Reverse issue lookup.
issue_branch_map = {}
git_config = {}
for config in RunGit(['config', '--get-regexp',
r'branch\..*issue']).splitlines():
name, _space, val = config.partition(' ')
git_config[name] = val
for branch in branches:
cl = Changelist(branchref=branch)
issue_branch_map.setdefault(cl.GetIssue(), []).append(branch)
for cls in _CODEREVIEW_IMPLEMENTATIONS.values():
config_key = _git_branch_config_key(ShortBranchName(branch),
cls.IssueConfigKey())
issue = git_config.get(config_key)
if issue:
issue_branch_map.setdefault(int(issue), []).append(branch)
if not args:
args = sorted(issue_branch_map.iterkeys())
result = {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment