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

Side by Side Diff: git_cache.py

Issue 545213002: Run prune in git cache update bootstrap to remove loose objects (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 3 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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 self.print('Error moving %s to %s: %s' % (tempdir, self.mirror_path, 418 self.print('Error moving %s to %s: %s' % (tempdir, self.mirror_path,
419 str(e))) 419 str(e)))
420 if not ignore_lock: 420 if not ignore_lock:
421 lockfile.unlock() 421 lockfile.unlock()
422 422
423 def update_bootstrap(self, prune=False): 423 def update_bootstrap(self, prune=False):
424 # The files are named <git number>.zip 424 # The files are named <git number>.zip
425 gen_number = subprocess.check_output( 425 gen_number = subprocess.check_output(
426 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() 426 [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip()
427 self.RunGit(['gc']) # Run Garbage Collect to compress packfile. 427 self.RunGit(['gc']) # Run Garbage Collect to compress packfile.
428 self.RunGit(['prune']) # Run prune to remove loose objects.
szager1 2014/09/05 16:49:36 Why not just: self.RunGit(['gc', '--prune=all'])
Ryan Tseng 2014/09/05 16:53:53 Didn't know I could do that. Done
428 # Creating a temp file and then deleting it ensures we can use this name. 429 # Creating a temp file and then deleting it ensures we can use this name.
429 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip') 430 _, tmp_zipfile = tempfile.mkstemp(suffix='.zip')
430 os.remove(tmp_zipfile) 431 os.remove(tmp_zipfile)
431 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path) 432 subprocess.call(['zip', '-r', tmp_zipfile, '.'], cwd=self.mirror_path)
432 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None) 433 gsutil = Gsutil(path=self.gsutil_exe, boto_path=None)
433 gs_folder = 'gs://%s/%s' % (self.bootstrap_bucket, self.basedir) 434 gs_folder = 'gs://%s/%s' % (self.bootstrap_bucket, self.basedir)
434 dest_name = '%s/%s.zip' % (gs_folder, gen_number) 435 dest_name = '%s/%s.zip' % (gs_folder, gen_number)
435 gsutil.call('cp', tmp_zipfile, dest_name) 436 gsutil.call('cp', tmp_zipfile, dest_name)
436 os.remove(tmp_zipfile) 437 os.remove(tmp_zipfile)
437 438
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 return options, args 685 return options, args
685 686
686 687
687 def main(argv): 688 def main(argv):
688 dispatcher = subcommand.CommandDispatcher(__name__) 689 dispatcher = subcommand.CommandDispatcher(__name__)
689 return dispatcher.execute(OptionParser(), argv) 690 return dispatcher.execute(OptionParser(), argv)
690 691
691 692
692 if __name__ == '__main__': 693 if __name__ == '__main__':
693 sys.exit(main(sys.argv[1:])) 694 sys.exit(main(sys.argv[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