| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 """Implements the Var syntax.""" | 150 """Implements the Var syntax.""" |
| 151 if var_name in self._custom_vars: | 151 if var_name in self._custom_vars: |
| 152 return self._custom_vars[var_name] | 152 return self._custom_vars[var_name] |
| 153 elif var_name in self._local_scope.get("vars", {}): | 153 elif var_name in self._local_scope.get("vars", {}): |
| 154 return self._local_scope["vars"][var_name] | 154 return self._local_scope["vars"][var_name] |
| 155 raise gclient_utils.Error("Var is not defined: %s" % var_name) | 155 raise gclient_utils.Error("Var is not defined: %s" % var_name) |
| 156 | 156 |
| 157 | 157 |
| 158 class GClient(GClientKeywords): | 158 class GClient(GClientKeywords): |
| 159 """Object that represent a gclient checkout.""" | 159 """Object that represent a gclient checkout.""" |
| 160 DEPS_FILE = 'DEPS' |
| 160 | 161 |
| 161 SUPPORTED_COMMANDS = [ | 162 SUPPORTED_COMMANDS = [ |
| 162 'cleanup', 'diff', 'export', 'pack', 'revert', 'status', 'update', | 163 'cleanup', 'diff', 'export', 'pack', 'revert', 'status', 'update', |
| 163 'runhooks' | 164 'runhooks' |
| 164 ] | 165 ] |
| 165 | 166 |
| 166 DEPS_OS_CHOICES = { | 167 DEPS_OS_CHOICES = { |
| 167 "win32": "win", | 168 "win32": "win", |
| 168 "win": "win", | 169 "win": "win", |
| 169 "cygwin": "win", | 170 "cygwin": "win", |
| 170 "darwin": "mac", | 171 "darwin": "mac", |
| 171 "mac": "mac", | 172 "mac": "mac", |
| 172 "unix": "unix", | 173 "unix": "unix", |
| 173 "linux": "unix", | 174 "linux": "unix", |
| 174 "linux2": "unix", | 175 "linux2": "unix", |
| 175 } | 176 } |
| 176 | 177 |
| 177 DEPS_FILE = 'DEPS' | |
| 178 | |
| 179 DEFAULT_CLIENT_FILE_TEXT = ("""\ | 178 DEFAULT_CLIENT_FILE_TEXT = ("""\ |
| 180 solutions = [ | 179 solutions = [ |
| 181 { "name" : "%(solution_name)s", | 180 { "name" : "%(solution_name)s", |
| 182 "url" : "%(solution_url)s", | 181 "url" : "%(solution_url)s", |
| 183 "custom_deps" : { | 182 "custom_deps" : { |
| 184 }, | 183 }, |
| 185 "safesync_url": "%(safesync_url)s" | 184 "safesync_url": "%(safesync_url)s" |
| 186 }, | 185 }, |
| 187 ] | 186 ] |
| 188 """) | 187 """) |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1033 if options.verbose: | 1032 if options.verbose: |
| 1034 # Print out the .gclient file. This is longer than if we just printed the | 1033 # Print out the .gclient file. This is longer than if we just printed the |
| 1035 # client dict, but more legible, and it might contain helpful comments. | 1034 # client dict, but more legible, and it might contain helpful comments. |
| 1036 print(client.config_content) | 1035 print(client.config_content) |
| 1037 options.force = True | 1036 options.force = True |
| 1038 options.nohooks = False | 1037 options.nohooks = False |
| 1039 return client.RunOnDeps('runhooks', args) | 1038 return client.RunOnDeps('runhooks', args) |
| 1040 | 1039 |
| 1041 | 1040 |
| 1042 def CMDrevinfo(parser, args): | 1041 def CMDrevinfo(parser, args): |
| 1043 """Outputs details for every dependencies.""" | 1042 """Output revision info mapping for the client and its dependencies. |
| 1044 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 1043 |
| 1045 help="override deps for the specified (comma-separated) " | 1044 This allows the capture of an overall "revision" for the source tree that |
| 1046 "platform(s); 'all' will process all deps_os " | 1045 can be used to reproduce the same tree in the future. It is only useful for |
| 1047 "references") | 1046 "unpinned dependencies", i.e. DEPS/deps references without a svn revision |
| 1048 parser.add_option("-s", "--snapshot", action="store_true", | 1047 number or a git hash. A git branch name isn't "pinned" since the actual |
| 1049 help="create a snapshot file of the current " | 1048 commit can change. |
| 1050 "version of all repositories") | 1049 """ |
| 1050 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', |
| 1051 help='override deps for the specified (comma-separated) ' |
| 1052 'platform(s); \'all\' will process all deps_os ' |
| 1053 'references') |
| 1054 parser.add_option('-s', '--snapshot', action='store_true', |
| 1055 help='creates a snapshot .gclient file of the current ' |
| 1056 'version of all repositories to reproduce the tree, ' |
| 1057 'implies -a') |
| 1051 (options, args) = parser.parse_args(args) | 1058 (options, args) = parser.parse_args(args) |
| 1052 client = GClient.LoadCurrentConfig(options) | 1059 client = GClient.LoadCurrentConfig(options) |
| 1053 if not client: | 1060 if not client: |
| 1054 raise gclient_utils.Error("client not configured; see 'gclient config'") | 1061 raise gclient_utils.Error("client not configured; see 'gclient config'") |
| 1055 client.PrintRevInfo() | 1062 client.PrintRevInfo() |
| 1056 return 0 | 1063 return 0 |
| 1057 | 1064 |
| 1058 | 1065 |
| 1059 def Command(name): | 1066 def Command(name): |
| 1060 return getattr(sys.modules[__name__], 'CMD' + name, None) | 1067 return getattr(sys.modules[__name__], 'CMD' + name, None) |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1132 return CMDhelp(parser, argv) | 1139 return CMDhelp(parser, argv) |
| 1133 except gclient_utils.Error, e: | 1140 except gclient_utils.Error, e: |
| 1134 print >> sys.stderr, 'Error: %s' % str(e) | 1141 print >> sys.stderr, 'Error: %s' % str(e) |
| 1135 return 1 | 1142 return 1 |
| 1136 | 1143 |
| 1137 | 1144 |
| 1138 if '__main__' == __name__: | 1145 if '__main__' == __name__: |
| 1139 sys.exit(Main(sys.argv[1:])) | 1146 sys.exit(Main(sys.argv[1:])) |
| 1140 | 1147 |
| 1141 # vim: ts=2:sw=2:tw=80:et: | 1148 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |