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

Side by Side Diff: git_cache.py

Issue 2492963002: bot_update: Use 'gclient' from same repository. (Closed)
Patch Set: Also don't ignore move errors in git cache. Created 4 years, 1 month 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 | recipe_modules/bot_update/resources/bot_update.py » ('j') | 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 self._fetch(rundir, verbose, depth) 432 self._fetch(rundir, verbose, depth)
433 except ClobberNeeded: 433 except ClobberNeeded:
434 # This is a major failure, we need to clean and force a bootstrap. 434 # This is a major failure, we need to clean and force a bootstrap.
435 gclient_utils.rmtree(rundir) 435 gclient_utils.rmtree(rundir)
436 self.print(GIT_CACHE_CORRUPT_MESSAGE) 436 self.print(GIT_CACHE_CORRUPT_MESSAGE)
437 tempdir = self._ensure_bootstrapped(depth, bootstrap, force=True) 437 tempdir = self._ensure_bootstrapped(depth, bootstrap, force=True)
438 assert tempdir 438 assert tempdir
439 self._fetch(tempdir or self.mirror_path, verbose, depth) 439 self._fetch(tempdir or self.mirror_path, verbose, depth)
440 finally: 440 finally:
441 if tempdir: 441 if tempdir:
442 try: 442 if os.path.exists(self.mirror_path):
443 if os.path.exists(self.mirror_path): 443 gclient_utils.rmtree(self.mirror_path)
444 gclient_utils.rmtree(self.mirror_path) 444 os.rename(tempdir, self.mirror_path)
445 os.rename(tempdir, self.mirror_path)
446 except OSError as e:
447 # This is somehow racy on Windows.
448 # Catching OSError because WindowsError isn't portable and
449 # pylint complains.
450 self.print('Error moving %s to %s: %s' % (tempdir, self.mirror_path,
451 str(e)))
452 if not ignore_lock: 445 if not ignore_lock:
453 lockfile.unlock() 446 lockfile.unlock()
454 447
455 def update_bootstrap(self, prune=False): 448 def update_bootstrap(self, prune=False):
456 # The files are named <git number>.zip 449 # The files are named <git number>.zip
457 gen_number = subprocess.check_output( 450 gen_number = subprocess.check_output(
458 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() 451 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip()
459 # Run Garbage Collect to compress packfile. 452 # Run Garbage Collect to compress packfile.
460 self.RunGit(['gc', '--prune=all']) 453 self.RunGit(['gc', '--prune=all'])
461 # Creating a temp file and then deleting it ensures we can use this name. 454 # Creating a temp file and then deleting it ensures we can use this name.
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 dispatcher = subcommand.CommandDispatcher(__name__) 722 dispatcher = subcommand.CommandDispatcher(__name__)
730 return dispatcher.execute(OptionParser(), argv) 723 return dispatcher.execute(OptionParser(), argv)
731 724
732 725
733 if __name__ == '__main__': 726 if __name__ == '__main__':
734 try: 727 try:
735 sys.exit(main(sys.argv[1:])) 728 sys.exit(main(sys.argv[1:]))
736 except KeyboardInterrupt: 729 except KeyboardInterrupt:
737 sys.stderr.write('interrupted\n') 730 sys.stderr.write('interrupted\n')
738 sys.exit(1) 731 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | recipe_modules/bot_update/resources/bot_update.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698