Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: git_cache.py

Issue 2031773002: git_cache.py: Clobber git repos if the config is corrupt (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A git command for managing a local cache of git repositories.""" 6 """A git command for managing a local cache of git repositories."""
7 7
8 from __future__ import print_function 8 from __future__ import print_function
9 import errno 9 import errno
10 import logging 10 import logging
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 env.setdefault('GIT_ASKPASS', 'true') 239 env.setdefault('GIT_ASKPASS', 'true')
240 env.setdefault('SSH_ASKPASS', 'true') 240 env.setdefault('SSH_ASKPASS', 'true')
241 self.print('running "git %s" in "%s"' % (' '.join(cmd), cwd)) 241 self.print('running "git %s" in "%s"' % (' '.join(cmd), cwd))
242 gclient_utils.CheckCallAndFilter([self.git_exe] + cmd, **kwargs) 242 gclient_utils.CheckCallAndFilter([self.git_exe] + cmd, **kwargs)
243 243
244 def config(self, cwd=None): 244 def config(self, cwd=None):
245 if cwd is None: 245 if cwd is None:
246 cwd = self.mirror_path 246 cwd = self.mirror_path
247 247
248 # Don't run git-gc in a daemon. Bad things can happen if it gets killed. 248 # Don't run git-gc in a daemon. Bad things can happen if it gets killed.
249 self.RunGit(['config', 'gc.autodetach', '0'], cwd=cwd) 249 try:
250 self.RunGit(['config', 'gc.autodetach', '0'], cwd=cwd)
251 except subprocess2.CalledProcessError:
252 # Hard error, need to clobber.
253 raise RefsHeadsFailedToFetch
Paweł Hajdan Jr. 2016/06/06 11:21:52 It seems hacky to re-use RefsHeadsFailedToFetch ex
Ryan Tseng 2016/06/07 20:38:02 Done.
250 254
251 # Don't combine pack files into one big pack file. It's really slow for 255 # Don't combine pack files into one big pack file. It's really slow for
252 # repositories, and there's no way to track progress and make sure it's 256 # repositories, and there's no way to track progress and make sure it's
253 # not stuck. 257 # not stuck.
254 self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd) 258 self.RunGit(['config', 'gc.autopacklimit', '0'], cwd=cwd)
255 259
256 # Allocate more RAM for cache-ing delta chains, for better performance 260 # Allocate more RAM for cache-ing delta chains, for better performance
257 # of "Resolving deltas". 261 # of "Resolving deltas".
258 self.RunGit(['config', 'core.deltaBaseCacheLimit', 262 self.RunGit(['config', 'core.deltaBaseCacheLimit',
259 gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=cwd) 263 gclient_utils.DefaultDeltaBaseCacheLimit()], cwd=cwd)
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 dispatcher = subcommand.CommandDispatcher(__name__) 729 dispatcher = subcommand.CommandDispatcher(__name__)
726 return dispatcher.execute(OptionParser(), argv) 730 return dispatcher.execute(OptionParser(), argv)
727 731
728 732
729 if __name__ == '__main__': 733 if __name__ == '__main__':
730 try: 734 try:
731 sys.exit(main(sys.argv[1:])) 735 sys.exit(main(sys.argv[1:]))
732 except KeyboardInterrupt: 736 except KeyboardInterrupt:
733 sys.stderr.write('interrupted\n') 737 sys.stderr.write('interrupted\n')
734 sys.exit(1) 738 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698