| OLD | NEW |
| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 dir=options.cache_dir) | 211 dir=options.cache_dir) |
| 212 RunGit(['init', '--bare'], cwd=tempdir) | 212 RunGit(['init', '--bare'], cwd=tempdir) |
| 213 _config(tempdir) | 213 _config(tempdir) |
| 214 fetch_cmd = ['fetch'] + v + d + ['--tags', 'origin'] | 214 fetch_cmd = ['fetch'] + v + d + ['--tags', 'origin'] |
| 215 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=tempdir, retry=True) | 215 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=tempdir, retry=True) |
| 216 os.rename(tempdir, repo_dir) | 216 os.rename(tempdir, repo_dir) |
| 217 else: | 217 else: |
| 218 _config(repo_dir) | 218 _config(repo_dir) |
| 219 if options.depth and os.path.exists(os.path.join(repo_dir, 'shallow')): | 219 if options.depth and os.path.exists(os.path.join(repo_dir, 'shallow')): |
| 220 logging.warn('Shallow fetch requested, but repo cache already exists.') | 220 logging.warn('Shallow fetch requested, but repo cache already exists.') |
| 221 fetch_cmd = ['fetch'] + v + ['--update-shallow', '--tags', 'origin'] | 221 fetch_cmd = ['fetch'] + v + ['--tags', 'origin'] |
| 222 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=repo_dir, retry=True) | 222 RunGit(fetch_cmd, filter_fn=filter_fn, cwd=repo_dir, retry=True) |
| 223 | 223 |
| 224 | 224 |
| 225 @subcommand.usage('[url of repo to unlock, or -a|--all]') | 225 @subcommand.usage('[url of repo to unlock, or -a|--all]') |
| 226 def CMDunlock(parser, args): | 226 def CMDunlock(parser, args): |
| 227 """Unlock one or all repos if their lock files are still around.""" | 227 """Unlock one or all repos if their lock files are still around.""" |
| 228 parser.add_option('--force', '-f', action='store_true', | 228 parser.add_option('--force', '-f', action='store_true', |
| 229 help='Actually perform the action') | 229 help='Actually perform the action') |
| 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') |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return options, args | 294 return options, args |
| 295 | 295 |
| 296 | 296 |
| 297 def main(argv): | 297 def main(argv): |
| 298 dispatcher = subcommand.CommandDispatcher(__name__) | 298 dispatcher = subcommand.CommandDispatcher(__name__) |
| 299 return dispatcher.execute(OptionParser(), argv) | 299 return dispatcher.execute(OptionParser(), argv) |
| 300 | 300 |
| 301 | 301 |
| 302 if __name__ == '__main__': | 302 if __name__ == '__main__': |
| 303 sys.exit(main(sys.argv[1:])) | 303 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |