mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
[scm] Add lock around all set calls
Bug: b/356935829 Change-Id: I886d20b71af26efd828d18cb1b01f1271f42d053 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5786165 Commit-Queue: Allen Li <ayatane@chromium.org> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
This commit is contained in:
17
scm.py
17
scm.py
@@ -404,16 +404,18 @@ class GitConfigStateReal(GitConfigStateBase):
|
||||
args = ['config', f'--{scope}', '--replace-all', key, value]
|
||||
if value_pattern is not None:
|
||||
args.append(value_pattern)
|
||||
GIT.Capture(args, cwd=self.root)
|
||||
with self._scope_lock(scope):
|
||||
GIT.Capture(args, cwd=self.root)
|
||||
|
||||
def unset_config(self, key: str, *, scope: GitConfigScope,
|
||||
missing_ok: bool):
|
||||
# NOTE: `git config` already canonicalizes key.
|
||||
accepted_retcodes = (0, 5) if missing_ok else (0, )
|
||||
try:
|
||||
GIT.Capture(['config', f'--{scope}', '--unset', key],
|
||||
cwd=self.root,
|
||||
accepted_retcodes=accepted_retcodes)
|
||||
with self._scope_lock(scope):
|
||||
GIT.Capture(['config', f'--{scope}', '--unset', key],
|
||||
cwd=self.root,
|
||||
accepted_retcodes=accepted_retcodes)
|
||||
except subprocess2.CalledProcessError as cpe:
|
||||
if cpe.returncode == 5:
|
||||
if b'multiple values' in cpe.stderr:
|
||||
@@ -429,9 +431,10 @@ class GitConfigStateReal(GitConfigStateBase):
|
||||
if value_pattern is not None:
|
||||
args.append(value_pattern)
|
||||
try:
|
||||
GIT.Capture(args,
|
||||
cwd=self.root,
|
||||
accepted_retcodes=accepted_retcodes)
|
||||
with self._scope_lock(scope):
|
||||
GIT.Capture(args,
|
||||
cwd=self.root,
|
||||
accepted_retcodes=accepted_retcodes)
|
||||
except subprocess2.CalledProcessError as cpe:
|
||||
if cpe.returncode == 5:
|
||||
raise GitConfigUnsetMissingValue(key, scope)
|
||||
|
||||
Reference in New Issue
Block a user