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

Side by Side Diff: git_cache.py

Issue 180243006: Make gclient_scm.py use cache_dir (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Remove cache_locks, also more membership tests. Created 6 years, 9 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 | « gclient_utils.py ('k') | tests/gclient_scm_test.py » ('j') | 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 import errno 8 import errno
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 parser.add_option('--all', '-a', action='store_true', 230 parser.add_option('--all', '-a', action='store_true',
231 help='Unlock all repository caches') 231 help='Unlock all repository caches')
232 options, args = parser.parse_args(args) 232 options, args = parser.parse_args(args)
233 if len(args) > 1 or (len(args) == 0 and not options.all): 233 if len(args) > 1 or (len(args) == 0 and not options.all):
234 parser.error('git cache unlock takes exactly one repo url, or --all') 234 parser.error('git cache unlock takes exactly one repo url, or --all')
235 235
236 if not options.all: 236 if not options.all:
237 url = args[0] 237 url = args[0]
238 repo_dirs = [os.path.join(options.cache_dir, UrlToCacheDir(url))] 238 repo_dirs = [os.path.join(options.cache_dir, UrlToCacheDir(url))]
239 else: 239 else:
240 repo_dirs = [path for path in os.listdir(options.cache_dir) 240 repo_dirs = [os.path.join(options.cache_dir, path)
241 if os.path.isdir(path)] 241 for path in os.listdir(options.cache_dir)
242 if os.path.isdir(os.path.join(options.cache_dir, path))]
242 lockfiles = [repo_dir + '.lock' for repo_dir in repo_dirs 243 lockfiles = [repo_dir + '.lock' for repo_dir in repo_dirs
243 if os.path.exists(repo_dir + '.lock')] 244 if os.path.exists(repo_dir + '.lock')]
244 245
245 if not options.force: 246 if not options.force:
246 parser.error('git cache unlock requires -f|--force to do anything. ' 247 parser.error('git cache unlock requires -f|--force to do anything. '
247 'Refusing to unlock the following repo caches: ' 248 'Refusing to unlock the following repo caches: '
248 ', '.join(lockfiles)) 249 ', '.join(lockfiles))
249 250
250 unlocked = [] 251 unlocked = []
251 untouched = [] 252 untouched = []
252 for repo_dir in repo_dirs: 253 for repo_dir in repo_dirs:
253 lf = Lockfile(repo_dir) 254 lf = Lockfile(repo_dir)
254 if lf.break_lock(): 255 if lf.break_lock():
256 config_lock = os.path.join(repo_dir, 'config.lock')
257 if os.path.exists(config_lock):
258 os.remove(config_lock)
255 unlocked.append(repo_dir) 259 unlocked.append(repo_dir)
256 else: 260 else:
257 untouched.append(repo_dir) 261 untouched.append(repo_dir)
258 262
259 if unlocked: 263 if unlocked:
260 logging.info('Broke locks on these caches: %s' % unlocked) 264 logging.info('Broke locks on these caches: %s' % unlocked)
261 if untouched: 265 if untouched:
262 logging.debug('Did not touch these caches: %s' % untouched) 266 logging.debug('Did not touch these caches: %s' % untouched)
263 267
264 268
(...skipping 29 matching lines...) Expand all
294 return options, args 298 return options, args
295 299
296 300
297 def main(argv): 301 def main(argv):
298 dispatcher = subcommand.CommandDispatcher(__name__) 302 dispatcher = subcommand.CommandDispatcher(__name__)
299 return dispatcher.execute(OptionParser(), argv) 303 return dispatcher.execute(OptionParser(), argv)
300 304
301 305
302 if __name__ == '__main__': 306 if __name__ == '__main__':
303 sys.exit(main(sys.argv[1:])) 307 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « gclient_utils.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698