OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Meta checkout manager supporting both Subversion and GIT. | 6 """Meta checkout manager supporting both Subversion and GIT. |
7 | 7 |
8 Files | 8 Files |
9 .gclient : Current client configuration, written by 'config' command. | 9 .gclient : Current client configuration, written by 'config' command. |
10 Format is a Python script defining 'solutions', a list whose | 10 Format is a Python script defining 'solutions', a list whose |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 if sys.hexversion < 0x02060000: | 1564 if sys.hexversion < 0x02060000: |
1565 print >> sys.stderr, ( | 1565 print >> sys.stderr, ( |
1566 '\nYour python version %s is unsupported, please upgrade.\n' % | 1566 '\nYour python version %s is unsupported, please upgrade.\n' % |
1567 sys.version.split(' ', 1)[0]) | 1567 sys.version.split(' ', 1)[0]) |
1568 return 2 | 1568 return 2 |
1569 colorama.init() | 1569 colorama.init() |
1570 try: | 1570 try: |
1571 # Make stdout auto-flush so buildbot doesn't kill us during lengthy | 1571 # Make stdout auto-flush so buildbot doesn't kill us during lengthy |
1572 # operations. Python as a strong tendency to buffer sys.stdout. | 1572 # operations. Python as a strong tendency to buffer sys.stdout. |
1573 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 1573 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
1574 # Make stdout annotated with the thread ids. | |
1575 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout) | |
1576 # Do it late so all commands are listed. | 1574 # Do it late so all commands are listed. |
1577 # Unused variable 'usage' | 1575 # Unused variable 'usage' |
1578 # pylint: disable=W0612 | 1576 # pylint: disable=W0612 |
1579 def to_str(fn): | 1577 def to_str(fn): |
1580 return ( | 1578 return ( |
1581 ' %s%-10s%s' % (Fore.GREEN, fn[3:], Fore.RESET) + | 1579 ' %s%-10s%s' % (Fore.GREEN, fn[3:], Fore.RESET) + |
1582 ' %s' % Command(fn[3:]).__doc__.split('\n')[0].strip()) | 1580 ' %s' % Command(fn[3:]).__doc__.split('\n')[0].strip()) |
1583 cmds = ( | 1581 cmds = ( |
1584 to_str(fn) for fn in dir(sys.modules[__name__]) if fn.startswith('CMD') | 1582 to_str(fn) for fn in dir(sys.modules[__name__]) if fn.startswith('CMD') |
1585 ) | 1583 ) |
1586 CMDhelp.usage = '\n\nCommands are:\n' + '\n'.join(cmds) | 1584 CMDhelp.usage = '\n\nCommands are:\n' + '\n'.join(cmds) |
1587 parser = Parser() | 1585 parser = Parser() |
1588 if argv: | 1586 if argv: |
| 1587 if not argv[0] in ('diff', 'pack'): |
| 1588 # Make stdout annotated with the thread ids. |
| 1589 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout) |
1589 command = Command(argv[0]) | 1590 command = Command(argv[0]) |
1590 if command: | 1591 if command: |
1591 # 'fix' the usage and the description now that we know the subcommand. | 1592 # 'fix' the usage and the description now that we know the subcommand. |
1592 GenUsage(parser, argv[0]) | 1593 GenUsage(parser, argv[0]) |
1593 return command(parser, argv[1:]) | 1594 return command(parser, argv[1:]) |
1594 # Not a known command. Default to help. | 1595 # Not a known command. Default to help. |
1595 GenUsage(parser, 'help') | 1596 GenUsage(parser, 'help') |
1596 return CMDhelp(parser, argv) | 1597 return CMDhelp(parser, argv) |
1597 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1598 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1598 print >> sys.stderr, 'Error: %s' % str(e) | 1599 print >> sys.stderr, 'Error: %s' % str(e) |
1599 return 1 | 1600 return 1 |
1600 | 1601 |
1601 | 1602 |
1602 if '__main__' == __name__: | 1603 if '__main__' == __name__: |
1603 fix_encoding.fix_encoding() | 1604 fix_encoding.fix_encoding() |
1604 sys.exit(Main(sys.argv[1:])) | 1605 sys.exit(Main(sys.argv[1:])) |
1605 | 1606 |
1606 # vim: ts=2:sw=2:tw=80:et: | 1607 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |