Use get_config to look up whether a branch is dormant

get_config is implemented by caching git config --list -z, rather than
shelling out for every key one-by-one. This reduces git map-branches
time on my machine from 1.2s to 0.6s.

Change-Id: I999f4b893d248c2f71a36ec0f2594e0cdf08a248
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5498461
Commit-Queue: David Benjamin <davidben@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
changes/61/5498461/4
David Benjamin 1 year ago committed by LUCI CQ
parent 54b27c0a13
commit 40a3fc4722

@ -31,7 +31,7 @@ import sys
from git_common import current_branch, upstream, tags, get_branches_info
from git_common import get_git_version, MIN_UPSTREAM_TRACK_GIT_VERSION, hash_one
from git_common import run
from git_common import get_config, run
import setup_color
@ -220,11 +220,7 @@ class BranchMapper(object):
if '/' in branch:
return False
is_dormant = run('config',
'--get',
'branch.{}.dormant'.format(branch),
accepted_retcodes=[0, 1])
return is_dormant == 'true'
return get_config(f'branch.{branch}.dormant') == 'true'
def __append_branch(self, branch, output, depth=0):
"""Recurses through the tree structure and appends an OutputLine to the

Loading…
Cancel
Save