From dcfe55f13f15e597373497675beaf89811d5d4f3 Mon Sep 17 00:00:00 2001 From: Andrii Shyshkalov Date: Sat, 21 Sep 2019 03:35:39 +0000 Subject: [PATCH] git-cache: add --gc-aggressive support. This will be used on internal cache updater. For instance, I've just compressed chromium/src resulting bootstrap files from 20GiB to 7.5 GiB. R=ehmaldonado Change-Id: I15411700eb2ac3a26d1c658a12288cc49e48fd48 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1802877 Reviewed-by: Edward Lesmes Commit-Queue: Andrii Shyshkalov --- git_cache.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/git_cache.py b/git_cache.py index 45c63b4e0..ab3d08926 100755 --- a/git_cache.py +++ b/git_cache.py @@ -572,7 +572,7 @@ class Mirror(object): if not ignore_lock: lockfile.unlock() - def update_bootstrap(self, prune=False): + def update_bootstrap(self, prune=False, gc_aggressive=False): # The folder is gen_number = subprocess.check_output( [self.git_exe, 'number', 'master'], cwd=self.mirror_path).strip() @@ -592,7 +592,10 @@ class Mirror(object): return # Run Garbage Collect to compress packfile. - self.RunGit(['gc', '--prune=all']) + gc_args = ['gc', '--prune=all'] + if gc_aggressive: + gc_args.append('--aggressive') + self.RunGit(gc_args) gsutil.call('-m', 'cp', '-r', src_name, dest_prefix) @@ -699,6 +702,8 @@ def CMDupdate_bootstrap(parser, args): print('Sorry, update bootstrap will not work on Windows.', file=sys.stderr) return 1 + parser.add_option('--gc-aggressive', action='store_true', + help='Run aggressive repacking of the repo.') parser.add_option('--prune', action='store_true', help='Prune all other cached bundles of the same repo.') @@ -710,7 +715,7 @@ def CMDupdate_bootstrap(parser, args): options, args = parser.parse_args(args) url = args[0] mirror = Mirror(url) - mirror.update_bootstrap(options.prune) + mirror.update_bootstrap(options.prune, options.gc_aggressive) return 0