[gclient] Reuse rev-parse output in verbose mode

If verbose mode is used, we call rev-parse x2 for each git dependency.
Reusing the value results in 10% reduction for gclient no-op sync (~2s
savings).

R=gavinmak@google.com

Change-Id: I7d1a0a13f2aea3df20b25816fef22ef777a12bf5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5146995
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
changes/95/5146995/4
Josip Sokcevic 2 years ago committed by LUCI CQ
parent edba22d4eb
commit 751c658593

@ -1036,11 +1036,6 @@ class GitWrapper(SCMWrapper):
'Fix the conflict and run gclient again.\n'
'See man git-rebase for details.\n' % (self.relpath, revision))
if verbose:
self.Print('Checked out revision %s' %
self.revinfo(options, (), None),
timestamp=False)
# If --reset and --delete_unversioned_trees are specified, remove any
# untracked directories.
if options.reset and options.delete_unversioned_trees:
@ -1058,7 +1053,10 @@ class GitWrapper(SCMWrapper):
self.Print('_____ removing unversioned directory %s' % path)
gclient_utils.rmtree(full_path)
return self._Capture(['rev-parse', '--verify', 'HEAD'])
rev_hash = self._Capture(['rev-parse', '--verify', 'HEAD'])
if verbose:
self.Print(f'Checked out revision {rev_hash}', timestamp=False)
return rev_hash
def revert(self, options, _args, file_list):
"""Reverts local modifications.

Loading…
Cancel
Save