OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 wrapper script to manage a set of client modules in different SCM. | 6 """A wrapper script to manage a set of client modules in different SCM. |
7 | 7 |
8 This script is intended to be used to help basic management of client | 8 This script is intended to be used to help basic management of client |
9 program sources residing in one or more Subversion modules and Git | 9 program sources residing in one or more Subversion modules and Git |
10 repositories, along with other modules it depends on, also in Subversion or Git, | 10 repositories, along with other modules it depends on, also in Subversion or Git, |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 1083 |
1084 def Main(argv): | 1084 def Main(argv): |
1085 """Doesn't parse the arguments here, just find the right subcommand to | 1085 """Doesn't parse the arguments here, just find the right subcommand to |
1086 execute.""" | 1086 execute.""" |
1087 try: | 1087 try: |
1088 # Do it late so all commands are listed. | 1088 # Do it late so all commands are listed. |
1089 CMDhelp.usage = ('\n\nCommands are:\n' + '\n'.join([ | 1089 CMDhelp.usage = ('\n\nCommands are:\n' + '\n'.join([ |
1090 ' %-10s %s' % (fn[3:], Command(fn[3:]).__doc__.split('\n')[0].strip()) | 1090 ' %-10s %s' % (fn[3:], Command(fn[3:]).__doc__.split('\n')[0].strip()) |
1091 for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')])) | 1091 for fn in dir(sys.modules[__name__]) if fn.startswith('CMD')])) |
1092 parser = optparse.OptionParser(version='%prog ' + __version__) | 1092 parser = optparse.OptionParser(version='%prog ' + __version__) |
1093 parser.add_option("-v", "--verbose", action="count", default=0, | 1093 parser.add_option('-v', '--verbose', action='count', default=0, |
1094 help="Produces additional output for diagnostics. Can be " | 1094 help='Produces additional output for diagnostics. Can be ' |
1095 "used up to three times for more logging info.") | 1095 'used up to three times for more logging info.') |
1096 parser.add_option("--gclientfile", metavar="FILENAME", | 1096 parser.add_option('--gclientfile', dest='config_filename', |
1097 dest="config_filename", | 1097 default=os.environ.get('GCLIENT_FILE', '.gclient'), |
1098 default=os.environ.get("GCLIENT_FILE", ".gclient"), | 1098 help='Specify an alternate %default file') |
1099 help="Specify an alternate .gclient file") | |
1100 # Integrate standard options processing. | 1099 # Integrate standard options processing. |
1101 old_parser = parser.parse_args | 1100 old_parser = parser.parse_args |
1102 def Parse(args): | 1101 def Parse(args): |
1103 (options, args) = old_parser(args) | 1102 (options, args) = old_parser(args) |
| 1103 level = None |
1104 if options.verbose == 2: | 1104 if options.verbose == 2: |
1105 logging.basicConfig(level=logging.INFO) | 1105 level = logging.INFO |
1106 elif options.verbose > 2: | 1106 elif options.verbose > 2: |
1107 logging.basicConfig(level=logging.DEBUG) | 1107 level = logging.DEBUG |
1108 options.entries_filename = options.config_filename + "_entries" | 1108 logging.basicConfig(level=level, |
| 1109 format='%(module)s(%(lineno)d) %(funcName)s:%(message)s') |
| 1110 options.entries_filename = options.config_filename + '_entries' |
1109 if not hasattr(options, 'revisions'): | 1111 if not hasattr(options, 'revisions'): |
1110 # GClient.RunOnDeps expects it even if not applicable. | 1112 # GClient.RunOnDeps expects it even if not applicable. |
1111 options.revisions = [] | 1113 options.revisions = [] |
1112 if not hasattr(options, 'head'): | 1114 if not hasattr(options, 'head'): |
1113 options.head = None | 1115 options.head = None |
| 1116 if not hasattr(options, 'nohooks'): |
| 1117 options.nohooks = True |
| 1118 if not hasattr(options, 'deps_os'): |
| 1119 options.deps_os = None |
1114 return (options, args) | 1120 return (options, args) |
1115 parser.parse_args = Parse | 1121 parser.parse_args = Parse |
1116 # We don't want wordwrapping in epilog (usually examples) | 1122 # We don't want wordwrapping in epilog (usually examples) |
1117 parser.format_epilog = lambda _: parser.epilog or '' | 1123 parser.format_epilog = lambda _: parser.epilog or '' |
1118 if argv: | 1124 if argv: |
1119 command = Command(argv[0]) | 1125 command = Command(argv[0]) |
1120 if command: | 1126 if command: |
1121 # "fix" the usage and the description now that we know the subcommand. | 1127 # 'fix' the usage and the description now that we know the subcommand. |
1122 GenUsage(parser, argv[0]) | 1128 GenUsage(parser, argv[0]) |
1123 return command(parser, argv[1:]) | 1129 return command(parser, argv[1:]) |
1124 # Not a known command. Default to help. | 1130 # Not a known command. Default to help. |
1125 GenUsage(parser, 'help') | 1131 GenUsage(parser, 'help') |
1126 return CMDhelp(parser, argv) | 1132 return CMDhelp(parser, argv) |
1127 except gclient_utils.Error, e: | 1133 except gclient_utils.Error, e: |
1128 print >> sys.stderr, "Error: %s" % str(e) | 1134 print >> sys.stderr, 'Error: %s' % str(e) |
1129 return 1 | 1135 return 1 |
1130 | 1136 |
1131 | 1137 |
1132 if "__main__" == __name__: | 1138 if '__main__' == __name__: |
1133 sys.exit(Main(sys.argv[1:])) | 1139 sys.exit(Main(sys.argv[1:])) |
1134 | 1140 |
1135 # vim: ts=2:sw=2:tw=80:et: | 1141 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |