[git_cache] Add option to break locks on populate.

R=ehmaldonado@chromium.org, tandrii@chromium.org

Change-Id: Icd7b0afc98e6d9365f74e8a6eb232700c6362d17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1842832
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 4d3892d..17b8cde 100755
--- a/git_cache.py
+++ b/git_cache.py
@@ -745,6 +745,9 @@
   parser.add_option('--ignore_locks', '--ignore-locks',
                     action='store_true',
                     help='Don\'t try to lock repository')
+  parser.add_option('--break-locks',
+                    action='store_true',
+                    help='Break any existing lock instead of just ignoring it')
   parser.add_option('--reset-fetch-config', action='store_true', default=False,
                     help='Reset the fetch config before populating the cache.')
 
@@ -754,6 +757,8 @@
   url = args[0]
 
   mirror = Mirror(url, refs=options.ref)
+  if options.break_locks:
+    mirror.unlock()
   kwargs = {
       'verbose': options.verbose,
       'shallow': options.shallow,