Chromium Code Reviews| Index: git_cache.py |
| diff --git a/git_cache.py b/git_cache.py |
| index 1b135d50b425ae9bdab8201a140ece0311390b2a..dcc92cb25ca61ced03405477aba48dc5741cd967 100755 |
| --- a/git_cache.py |
| +++ b/git_cache.py |
| @@ -317,7 +317,7 @@ class Mirror(object): |
| return os.path.isfile(os.path.join(self.mirror_path, 'config')) |
| def populate(self, depth=None, shallow=False, bootstrap=False, |
| - verbose=False): |
| + verbose=False, ignore_lock=False): |
| assert self.GetCachePath() |
| if shallow and not depth: |
| depth = 10000 |
| @@ -332,7 +332,11 @@ class Mirror(object): |
| d = ['--depth', str(depth)] |
| - with Lockfile(self.mirror_path): |
| + lockfile = Lockfile(self.mirror_path) |
| + if not ignore_lock: |
| + lockfile.lock() |
| + |
| + try: |
| # Setup from scratch if the repo is new or is in a bad state. |
| tempdir = None |
| config_file = os.path.join(self.mirror_path, 'config') |
| @@ -380,6 +384,9 @@ class Mirror(object): |
| logging.warn('Fetch of %s failed' % spec) |
| if tempdir: |
| os.rename(tempdir, self.mirror_path) |
| + finally: |
| + if not ignore_lock: |
| + lockfile.unlock() |
| def update_bootstrap(self): |
| # The files are named <git number>.zip |
| @@ -497,6 +504,8 @@ def CMDpopulate(parser, args): |
| help='Specify additional refs to be fetched') |
| parser.add_option('--no_bootstrap', action='store_true', |
| help='Don\'t bootstrap from Google Storage') |
| + parser.add_option('--ignore-locks', action='store_true', |
|
Ryan Tseng
2014/06/18 23:54:39
--ignore_locks (matches no_bootstrap)
szager1
2014/06/19 20:35:33
Done.
|
| + help='Don\'t try to lock repository') |
| options, args = parser.parse_args(args) |
| if not len(args) == 1: |
| @@ -508,6 +517,7 @@ def CMDpopulate(parser, args): |
| 'verbose': options.verbose, |
| 'shallow': options.shallow, |
| 'bootstrap': not options.no_bootstrap, |
| + 'ignore_lock': options.ignore_locks, |
| } |
| if options.depth: |
| kwargs['depth'] = options.depth |