Commit e0dff208 authored by Antonio Sartori's avatar Antonio Sartori Committed by LUCI CQ

Make git map-branches faster

This change makes git map-branches a little bit faster by avoiding
fetching the revision list of each branch if git map-branches will not
show the tracking info anyway.

Change-Id: I47458871f904004f910aadd7d774bea5193c979e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2695393Reviewed-by: 's avatarAnthony Polito <apolito@google.com>
Commit-Queue: Antonio Sartori <antoniosartori@chromium.org>
parent 5e37f6de
......@@ -1045,10 +1045,11 @@ def get_branches_info(include_tracking_status):
(branch, branch_hash, upstream_branch, tracking_status) = line.split(':')
commits = None
base = get_or_create_merge_base(branch)
if base:
commits_list = run('rev-list', '--count', branch, '^%s' % base, '--')
commits = int(commits_list) or None
if include_tracking_status:
base = get_or_create_merge_base(branch)
if base:
commits_list = run('rev-list', '--count', branch, '^%s' % base, '--')
commits = int(commits_list) or None
behind_match = re.search(r'behind (\d+)', tracking_status)
behind = int(behind_match.group(1)) if behind_match else None
......
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