Chromium Code Reviews| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 self._fetch(rundir, verbose, depth) | 399 self._fetch(rundir, verbose, depth) |
| 400 except RefsHeadsFailedToFetch: | 400 except RefsHeadsFailedToFetch: |
| 401 # This is a major failure, we need to clean and force a bootstrap. | 401 # This is a major failure, we need to clean and force a bootstrap. |
| 402 gclient_utils.rmtree(rundir) | 402 gclient_utils.rmtree(rundir) |
| 403 self.print(GIT_CACHE_CORRUPT_MESSAGE) | 403 self.print(GIT_CACHE_CORRUPT_MESSAGE) |
| 404 tempdir = self._ensure_bootstrapped(depth, bootstrap, force=True) | 404 tempdir = self._ensure_bootstrapped(depth, bootstrap, force=True) |
| 405 assert tempdir | 405 assert tempdir |
| 406 self._fetch(tempdir or self.mirror_path, verbose, depth) | 406 self._fetch(tempdir or self.mirror_path, verbose, depth) |
| 407 finally: | 407 finally: |
| 408 if tempdir: | 408 if tempdir: |
| 409 os.rename(tempdir, self.mirror_path) | 409 try: |
| 410 os.rename(tempdir, self.mirror_path) | |
| 411 except WindowsError: | |
| 412 # This is somehow racy on Windows. | |
|
iannucci
2014/07/19 01:00:52
this will rely on the unlock all functionality in
| |
| 413 pass | |
| 410 if not ignore_lock: | 414 if not ignore_lock: |
| 411 lockfile.unlock() | 415 lockfile.unlock() |
| 412 | 416 |
| 413 def update_bootstrap(self, prune=False): | 417 def update_bootstrap(self, prune=False): |
| 414 # The files are named <git number>.zip | 418 # The files are named <git number>.zip |
| 415 gen_number = subprocess.check_output( | 419 gen_number = subprocess.check_output( |
| 416 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() | 420 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() |
| 417 self.RunGit(['gc']) # Run Garbage Collect to compress packfile. | 421 self.RunGit(['gc']) # Run Garbage Collect to compress packfile. |
| 418 # Creating a temp file and then deleting it ensures we can use this name. | 422 # Creating a temp file and then deleting it ensures we can use this name. |
| 419 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') | 423 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 return options, args | 628 return options, args |
| 625 | 629 |
| 626 | 630 |
| 627 def main(argv): | 631 def main(argv): |
| 628 dispatcher = subcommand.CommandDispatcher(__name__) | 632 dispatcher = subcommand.CommandDispatcher(__name__) |
| 629 return dispatcher.execute(OptionParser(), argv) | 633 return dispatcher.execute(OptionParser(), argv) |
| 630 | 634 |
| 631 | 635 |
| 632 if __name__ == '__main__': | 636 if __name__ == '__main__': |
| 633 sys.exit(main(sys.argv[1:])) | 637 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |