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 from __future__ import print_function | 8 from __future__ import print_function |
9 import errno | 9 import errno |
10 import logging | 10 import logging |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 # Lets just assert we can't do this on Windows. | 515 # Lets just assert we can't do this on Windows. |
516 if sys.platform.startswith('win'): | 516 if sys.platform.startswith('win'): |
517 print('Sorry, update bootstrap will not work on Windows.', file=sys.stderr) | 517 print('Sorry, update bootstrap will not work on Windows.', file=sys.stderr) |
518 return 1 | 518 return 1 |
519 | 519 |
520 parser.add_option('--prune', action='store_true', | 520 parser.add_option('--prune', action='store_true', |
521 help='Prune all other cached zipballs of the same repo.') | 521 help='Prune all other cached zipballs of the same repo.') |
522 | 522 |
523 # First, we need to ensure the cache is populated. | 523 # First, we need to ensure the cache is populated. |
524 populate_args = args[:] | 524 populate_args = args[:] |
525 populate_args.append('--no_bootstrap') | 525 populate_args.append('--no-bootstrap') |
526 CMDpopulate(parser, populate_args) | 526 CMDpopulate(parser, populate_args) |
527 | 527 |
528 # Get the repo directory. | 528 # Get the repo directory. |
529 options, args = parser.parse_args(args) | 529 options, args = parser.parse_args(args) |
530 url = args[0] | 530 url = args[0] |
531 mirror = Mirror(url) | 531 mirror = Mirror(url) |
532 mirror.update_bootstrap(options.prune) | 532 mirror.update_bootstrap(options.prune) |
533 return 0 | 533 return 0 |
534 | 534 |
535 | 535 |
536 @subcommand.usage('[url of repo to add to or update in cache]') | 536 @subcommand.usage('[url of repo to add to or update in cache]') |
537 def CMDpopulate(parser, args): | 537 def CMDpopulate(parser, args): |
538 """Ensure that the cache has all up-to-date objects for the given repo.""" | 538 """Ensure that the cache has all up-to-date objects for the given repo.""" |
539 parser.add_option('--depth', type='int', | 539 parser.add_option('--depth', type='int', |
540 help='Only cache DEPTH commits of history') | 540 help='Only cache DEPTH commits of history') |
541 parser.add_option('--shallow', '-s', action='store_true', | 541 parser.add_option('--shallow', '-s', action='store_true', |
542 help='Only cache 10000 commits of history') | 542 help='Only cache 10000 commits of history') |
543 parser.add_option('--ref', action='append', | 543 parser.add_option('--ref', action='append', |
544 help='Specify additional refs to be fetched') | 544 help='Specify additional refs to be fetched') |
545 parser.add_option('--no_bootstrap', action='store_true', | 545 parser.add_option('--no_bootstrap', '--no-bootstrap', |
| 546 action='store_true', |
546 help='Don\'t bootstrap from Google Storage') | 547 help='Don\'t bootstrap from Google Storage') |
547 parser.add_option('--ignore_locks', action='store_true', | 548 parser.add_option('--ignore_locks', '--ignore-locks', |
| 549 action='store_true', |
548 help='Don\'t try to lock repository') | 550 help='Don\'t try to lock repository') |
549 | 551 |
550 options, args = parser.parse_args(args) | 552 options, args = parser.parse_args(args) |
551 if not len(args) == 1: | 553 if not len(args) == 1: |
552 parser.error('git cache populate only takes exactly one repo url.') | 554 parser.error('git cache populate only takes exactly one repo url.') |
553 url = args[0] | 555 url = args[0] |
554 | 556 |
555 mirror = Mirror(url, refs=options.ref) | 557 mirror = Mirror(url, refs=options.ref) |
556 kwargs = { | 558 kwargs = { |
557 'verbose': options.verbose, | 559 'verbose': options.verbose, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 return options, args | 633 return options, args |
632 | 634 |
633 | 635 |
634 def main(argv): | 636 def main(argv): |
635 dispatcher = subcommand.CommandDispatcher(__name__) | 637 dispatcher = subcommand.CommandDispatcher(__name__) |
636 return dispatcher.execute(OptionParser(), argv) | 638 return dispatcher.execute(OptionParser(), argv) |
637 | 639 |
638 | 640 |
639 if __name__ == '__main__': | 641 if __name__ == '__main__': |
640 sys.exit(main(sys.argv[1:])) | 642 sys.exit(main(sys.argv[1:])) |
OLD | NEW |