[git-cache] Add option to update_bootstrap to skip the populate step.

This will allow us to separate the 'populate' and 'upload' phases
in the git cache updater recipe, which will allow us to do all the
'populate' steps in parallel, but then limit the parallelism of the
`pack/gc/upload` operations.

R=tandrii@chromium.org

Change-Id: I8b8a9155f86350be37ed5a67c592ff1fec4d42ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1830857
Auto-Submit: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@google.com>
Reviewed-by: Andrii Shyshkalov <tandrii@google.com>
diff --git a/git_cache.py b/git_cache.py
index 6b8cd7f..8d050c3 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -700,14 +700,21 @@
     print('Sorry, update bootstrap will not work on Windows.', file=sys.stderr)
     return 1
 
+  parser.add_option('--skip-populate', action='store_true',
+                    help='Skips "populate" step if mirror already exists.')
   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.')
 
-  # First, we need to ensure the cache is populated.
   populate_args = args[:]
-  CMDpopulate(parser, populate_args)
+  options, args = parser.parse_args(args)
+  url = args[0]
+  mirror = Mirror(url)
+  if not options.skip_populate or not mirror.exists():
+    CMDpopulate(parser, populate_args)
+  else:
+    print('Skipped populate step.')
 
   # Get the repo directory.
   options, args = parser.parse_args(args)