OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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) |
OLD | NEW |