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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 """Sets an attribute on a function.""" | 78 """Sets an attribute on a function.""" |
79 def hook(fn): | 79 def hook(fn): |
80 setattr(fn, attr, data) | 80 setattr(fn, attr, data) |
81 return fn | 81 return fn |
82 return hook | 82 return hook |
83 | 83 |
84 | 84 |
85 ## GClient implementation. | 85 ## GClient implementation. |
86 | 86 |
87 | 87 |
88 class GClient(object): | 88 class GClientKeywords(object): |
| 89 class FromImpl(object): |
| 90 """Used to implement the From() syntax.""" |
| 91 |
| 92 def __init__(self, module_name, sub_target_name=None): |
| 93 """module_name is the dep module we want to include from. It can also be |
| 94 the name of a subdirectory to include from. |
| 95 |
| 96 sub_target_name is an optional parameter if the module name in the other |
| 97 DEPS file is different. E.g., you might want to map src/net to net.""" |
| 98 self.module_name = module_name |
| 99 self.sub_target_name = sub_target_name |
| 100 |
| 101 def __str__(self): |
| 102 return 'From(%s, %s)' % (repr(self.module_name), |
| 103 repr(self.sub_target_name)) |
| 104 |
| 105 def GetUrl(self, target_name, sub_deps_base_url, root_dir, sub_deps): |
| 106 """Resolve the URL for this From entry.""" |
| 107 sub_deps_target_name = target_name |
| 108 if self.sub_target_name: |
| 109 sub_deps_target_name = self.sub_target_name |
| 110 url = sub_deps[sub_deps_target_name] |
| 111 if url.startswith('/'): |
| 112 # If it's a relative URL, we need to resolve the URL relative to the |
| 113 # sub deps base URL. |
| 114 if not isinstance(sub_deps_base_url, basestring): |
| 115 sub_deps_base_url = sub_deps_base_url.GetPath() |
| 116 scm = gclient_scm.CreateSCM(sub_deps_base_url, root_dir, |
| 117 None) |
| 118 url = scm.FullUrlForRelativeUrl(url) |
| 119 return url |
| 120 |
| 121 class FileImpl(object): |
| 122 """Used to implement the File('') syntax which lets you sync a single file |
| 123 from an SVN repo.""" |
| 124 |
| 125 def __init__(self, file_location): |
| 126 self.file_location = file_location |
| 127 |
| 128 def __str__(self): |
| 129 return 'File("%s")' % self.file_location |
| 130 |
| 131 def GetPath(self): |
| 132 return os.path.split(self.file_location)[0] |
| 133 |
| 134 def GetFilename(self): |
| 135 rev_tokens = self.file_location.split('@') |
| 136 return os.path.split(rev_tokens[0])[1] |
| 137 |
| 138 def GetRevision(self): |
| 139 rev_tokens = self.file_location.split('@') |
| 140 if len(rev_tokens) > 1: |
| 141 return rev_tokens[1] |
| 142 return None |
| 143 |
| 144 class VarImpl(object): |
| 145 def __init__(self, custom_vars, local_scope): |
| 146 self._custom_vars = custom_vars |
| 147 self._local_scope = local_scope |
| 148 |
| 149 def Lookup(self, var_name): |
| 150 """Implements the Var syntax.""" |
| 151 if var_name in self._custom_vars: |
| 152 return self._custom_vars[var_name] |
| 153 elif var_name in self._local_scope.get("vars", {}): |
| 154 return self._local_scope["vars"][var_name] |
| 155 raise gclient_utils.Error("Var is not defined: %s" % var_name) |
| 156 |
| 157 |
| 158 class GClient(GClientKeywords): |
89 """Object that represent a gclient checkout.""" | 159 """Object that represent a gclient checkout.""" |
90 | 160 |
91 supported_commands = [ | 161 SUPPORTED_COMMANDS = [ |
92 'cleanup', 'diff', 'export', 'pack', 'revert', 'status', 'update', | 162 'cleanup', 'diff', 'export', 'pack', 'revert', 'status', 'update', |
93 'runhooks' | 163 'runhooks' |
94 ] | 164 ] |
95 | 165 |
96 deps_os_choices = { | 166 DEPS_OS_CHOICES = { |
97 "win32": "win", | 167 "win32": "win", |
98 "win": "win", | 168 "win": "win", |
99 "cygwin": "win", | 169 "cygwin": "win", |
100 "darwin": "mac", | 170 "darwin": "mac", |
101 "mac": "mac", | 171 "mac": "mac", |
102 "unix": "unix", | 172 "unix": "unix", |
103 "linux": "unix", | 173 "linux": "unix", |
104 "linux2": "unix", | 174 "linux2": "unix", |
105 } | 175 } |
106 | 176 |
(...skipping 23 matching lines...) Expand all Loading... |
130 DEFAULT_SNAPSHOT_FILE_TEXT = ("""\ | 200 DEFAULT_SNAPSHOT_FILE_TEXT = ("""\ |
131 # Snapshot generated with gclient revinfo --snapshot | 201 # Snapshot generated with gclient revinfo --snapshot |
132 solutions = [ | 202 solutions = [ |
133 %(solution_list)s | 203 %(solution_list)s |
134 ] | 204 ] |
135 """) | 205 """) |
136 | 206 |
137 def __init__(self, root_dir, options): | 207 def __init__(self, root_dir, options): |
138 self._root_dir = root_dir | 208 self._root_dir = root_dir |
139 self._options = options | 209 self._options = options |
140 self._config_content = None | 210 self.config_content = None |
141 self._config_dict = {} | 211 self._config_dict = {} |
142 self._deps_hooks = [] | 212 self._deps_hooks = [] |
143 | 213 |
144 def SetConfig(self, content): | 214 def SetConfig(self, content): |
145 self._config_dict = {} | 215 self._config_dict = {} |
146 self._config_content = content | 216 self.config_content = content |
147 try: | 217 try: |
148 exec(content, self._config_dict) | 218 exec(content, self._config_dict) |
149 except SyntaxError, e: | 219 except SyntaxError, e: |
150 try: | 220 try: |
151 __pychecker__ = 'no-objattrs' | 221 __pychecker__ = 'no-objattrs' |
152 # Try to construct a human readable error message | 222 # Try to construct a human readable error message |
153 error_message = [ | 223 error_message = [ |
154 'There is a syntax error in your configuration file.', | 224 'There is a syntax error in your configuration file.', |
155 'Line #%s, character %s:' % (e.lineno, e.offset), | 225 'Line #%s, character %s:' % (e.lineno, e.offset), |
156 '"%s"' % re.sub(r'[\r\n]*$', '', e.text) ] | 226 '"%s"' % re.sub(r'[\r\n]*$', '', e.text) ] |
157 except: | 227 except: |
158 # Something went wrong, re-raise the original exception | 228 # Something went wrong, re-raise the original exception |
159 raise e | 229 raise e |
160 else: | 230 else: |
161 # Raise a new exception with the human readable message: | 231 # Raise a new exception with the human readable message: |
162 raise gclient_utils.Error('\n'.join(error_message)) | 232 raise gclient_utils.Error('\n'.join(error_message)) |
163 | 233 |
164 def SaveConfig(self): | 234 def SaveConfig(self): |
165 gclient_utils.FileWrite(os.path.join(self._root_dir, | 235 gclient_utils.FileWrite(os.path.join(self._root_dir, |
166 self._options.config_filename), | 236 self._options.config_filename), |
167 self._config_content) | 237 self.config_content) |
168 | 238 |
169 def _LoadConfig(self): | 239 def _LoadConfig(self): |
170 client_source = gclient_utils.FileRead( | 240 client_source = gclient_utils.FileRead( |
171 os.path.join(self._root_dir, self._options.config_filename)) | 241 os.path.join(self._root_dir, self._options.config_filename)) |
172 self.SetConfig(client_source) | 242 self.SetConfig(client_source) |
173 | 243 |
174 def ConfigContent(self): | |
175 return self._config_content | |
176 | |
177 def GetVar(self, key, default=None): | 244 def GetVar(self, key, default=None): |
178 return self._config_dict.get(key, default) | 245 return self._config_dict.get(key, default) |
179 | 246 |
180 @staticmethod | 247 @staticmethod |
181 def LoadCurrentConfig(options, from_dir=None): | 248 def LoadCurrentConfig(options, from_dir=None): |
182 """Searches for and loads a .gclient file relative to the current working | 249 """Searches for and loads a .gclient file relative to the current working |
183 dir. | 250 dir. |
184 | 251 |
185 Returns: | 252 Returns: |
186 A dict representing the contents of the .gclient file or an empty dict if | 253 A dict representing the contents of the .gclient file or an empty dict if |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 A sequence of solution names, which will be empty if there is the | 299 A sequence of solution names, which will be empty if there is the |
233 entries file hasn't been created yet. | 300 entries file hasn't been created yet. |
234 """ | 301 """ |
235 scope = {} | 302 scope = {} |
236 filename = os.path.join(self._root_dir, self._options.entries_filename) | 303 filename = os.path.join(self._root_dir, self._options.entries_filename) |
237 if not os.path.exists(filename): | 304 if not os.path.exists(filename): |
238 return [] | 305 return [] |
239 exec(gclient_utils.FileRead(filename), scope) | 306 exec(gclient_utils.FileRead(filename), scope) |
240 return scope["entries"] | 307 return scope["entries"] |
241 | 308 |
242 class FromImpl: | |
243 """Used to implement the From syntax.""" | |
244 | |
245 def __init__(self, module_name, sub_target_name=None): | |
246 """module_name is the dep module we want to include from. It can also be | |
247 the name of a subdirectory to include from. | |
248 | |
249 sub_target_name is an optional parameter if the module name in the other | |
250 DEPS file is different. E.g., you might want to map src/net to net.""" | |
251 self.module_name = module_name | |
252 self.sub_target_name = sub_target_name | |
253 | |
254 def __str__(self): | |
255 return 'From(%s, %s)' % (repr(self.module_name), | |
256 repr(self.sub_target_name)) | |
257 | |
258 def GetUrl(self, target_name, sub_deps_base_url, root_dir, sub_deps): | |
259 """Resolve the URL for this From entry.""" | |
260 sub_deps_target_name = target_name | |
261 if self.sub_target_name: | |
262 sub_deps_target_name = self.sub_target_name | |
263 url = sub_deps[sub_deps_target_name] | |
264 if url.startswith('/'): | |
265 # If it's a relative URL, we need to resolve the URL relative to the | |
266 # sub deps base URL. | |
267 if not isinstance(sub_deps_base_url, basestring): | |
268 sub_deps_base_url = sub_deps_base_url.GetPath() | |
269 scm = gclient_scm.CreateSCM(sub_deps_base_url, root_dir, | |
270 None) | |
271 url = scm.FullUrlForRelativeUrl(url) | |
272 return url | |
273 | |
274 class FileImpl: | |
275 """Used to implement the File('') syntax which lets you sync a single file | |
276 from an SVN repo.""" | |
277 | |
278 def __init__(self, file_location): | |
279 self.file_location = file_location | |
280 | |
281 def __str__(self): | |
282 return 'File("%s")' % self.file_location | |
283 | |
284 def GetPath(self): | |
285 return os.path.split(self.file_location)[0] | |
286 | |
287 def GetFilename(self): | |
288 rev_tokens = self.file_location.split('@') | |
289 return os.path.split(rev_tokens[0])[1] | |
290 | |
291 def GetRevision(self): | |
292 rev_tokens = self.file_location.split('@') | |
293 if len(rev_tokens) > 1: | |
294 return rev_tokens[1] | |
295 return None | |
296 | |
297 class _VarImpl: | |
298 def __init__(self, custom_vars, local_scope): | |
299 self._custom_vars = custom_vars | |
300 self._local_scope = local_scope | |
301 | |
302 def Lookup(self, var_name): | |
303 """Implements the Var syntax.""" | |
304 if var_name in self._custom_vars: | |
305 return self._custom_vars[var_name] | |
306 elif var_name in self._local_scope.get("vars", {}): | |
307 return self._local_scope["vars"][var_name] | |
308 raise gclient_utils.Error("Var is not defined: %s" % var_name) | |
309 | |
310 def _ParseSolutionDeps(self, solution_name, solution_deps_content, | 309 def _ParseSolutionDeps(self, solution_name, solution_deps_content, |
311 custom_vars, parse_hooks): | 310 custom_vars, parse_hooks): |
312 """Parses the DEPS file for the specified solution. | 311 """Parses the DEPS file for the specified solution. |
313 | 312 |
314 Args: | 313 Args: |
315 solution_name: The name of the solution to query. | 314 solution_name: The name of the solution to query. |
316 solution_deps_content: Content of the DEPS file for the solution | 315 solution_deps_content: Content of the DEPS file for the solution |
317 custom_vars: A dict of vars to override any vars defined in the DEPS file. | 316 custom_vars: A dict of vars to override any vars defined in the DEPS file. |
318 | 317 |
319 Returns: | 318 Returns: |
320 A dict mapping module names (as relative paths) to URLs or an empty | 319 A dict mapping module names (as relative paths) to URLs or an empty |
321 dict if the solution does not have a DEPS file. | 320 dict if the solution does not have a DEPS file. |
322 """ | 321 """ |
323 # Skip empty | 322 # Skip empty |
324 if not solution_deps_content: | 323 if not solution_deps_content: |
325 return {} | 324 return {} |
326 # Eval the content | 325 # Eval the content |
327 local_scope = {} | 326 local_scope = {} |
328 var = self._VarImpl(custom_vars, local_scope) | 327 var = self.VarImpl(custom_vars, local_scope) |
329 global_scope = { | 328 global_scope = { |
330 "File": self.FileImpl, | 329 "File": self.FileImpl, |
331 "From": self.FromImpl, | 330 "From": self.FromImpl, |
332 "Var": var.Lookup, | 331 "Var": var.Lookup, |
333 "deps_os": {}, | 332 "deps_os": {}, |
334 } | 333 } |
335 exec(solution_deps_content, global_scope, local_scope) | 334 exec(solution_deps_content, global_scope, local_scope) |
336 deps = local_scope.get("deps", {}) | 335 deps = local_scope.get("deps", {}) |
337 | 336 |
338 # load os specific dependencies if defined. these dependencies may | 337 # load os specific dependencies if defined. these dependencies may |
339 # override or extend the values defined by the 'deps' member. | 338 # override or extend the values defined by the 'deps' member. |
340 if "deps_os" in local_scope: | 339 if "deps_os" in local_scope: |
341 if self._options.deps_os is not None: | 340 if self._options.deps_os is not None: |
342 deps_to_include = self._options.deps_os.split(",") | 341 deps_to_include = self._options.deps_os.split(",") |
343 if "all" in deps_to_include: | 342 if "all" in deps_to_include: |
344 deps_to_include = list(set(self.deps_os_choices.itervalues())) | 343 deps_to_include = list(set(self.DEPS_OS_CHOICES.itervalues())) |
345 else: | 344 else: |
346 deps_to_include = [self.deps_os_choices.get(sys.platform, "unix")] | 345 deps_to_include = [self.DEPS_OS_CHOICES.get(sys.platform, "unix")] |
347 | 346 |
348 deps_to_include = set(deps_to_include) | 347 deps_to_include = set(deps_to_include) |
349 for deps_os_key in deps_to_include: | 348 for deps_os_key in deps_to_include: |
350 os_deps = local_scope["deps_os"].get(deps_os_key, {}) | 349 os_deps = local_scope["deps_os"].get(deps_os_key, {}) |
351 if len(deps_to_include) > 1: | 350 if len(deps_to_include) > 1: |
352 # Ignore any overrides when including deps for more than one | 351 # Ignore any overrides when including deps for more than one |
353 # platform, so we collect the broadest set of dependencies available. | 352 # platform, so we collect the broadest set of dependencies available. |
354 # We may end up with the wrong revision of something for our | 353 # We may end up with the wrong revision of something for our |
355 # platform, but this is the best we can do. | 354 # platform, but this is the best we can do. |
356 deps.update([x for x in os_deps.items() if not x[0] in deps]) | 355 deps.update([x for x in os_deps.items() if not x[0] in deps]) |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 539 |
541 The module's dependencies are specified in its top-level DEPS files. | 540 The module's dependencies are specified in its top-level DEPS files. |
542 | 541 |
543 Args: | 542 Args: |
544 command: The command to use (e.g., 'status' or 'diff') | 543 command: The command to use (e.g., 'status' or 'diff') |
545 args: list of str - extra arguments to add to the command line. | 544 args: list of str - extra arguments to add to the command line. |
546 | 545 |
547 Raises: | 546 Raises: |
548 Error: If the client has conflicting entries. | 547 Error: If the client has conflicting entries. |
549 """ | 548 """ |
550 if not command in self.supported_commands: | 549 if not command in self.SUPPORTED_COMMANDS: |
551 raise gclient_utils.Error("'%s' is an unsupported command" % command) | 550 raise gclient_utils.Error("'%s' is an unsupported command" % command) |
552 | 551 |
553 solutions = self.GetVar("solutions") | 552 solutions = self.GetVar("solutions") |
554 if not solutions: | 553 if not solutions: |
555 raise gclient_utils.Error("No solution specified") | 554 raise gclient_utils.Error("No solution specified") |
556 revision_overrides = self._EnforceRevisions(solutions) | 555 revision_overrides = self._EnforceRevisions(solutions) |
557 | 556 |
558 # When running runhooks --force, there's no need to consult the SCM. | 557 # When running runhooks --force, there's no need to consult the SCM. |
559 # All known hooks are expected to run unconditionally regardless of working | 558 # All known hooks are expected to run unconditionally regardless of working |
560 # copy state, so skip the SCM status check. | 559 # copy state, so skip the SCM status check. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 } | 785 } |
787 else: | 786 else: |
788 print(";\n".join(["%s: %s" % (x, entries[x]) | 787 print(";\n".join(["%s: %s" % (x, entries[x]) |
789 for x in sorted(entries.keys())])) | 788 for x in sorted(entries.keys())])) |
790 | 789 |
791 # Print the snapshot configuration file | 790 # Print the snapshot configuration file |
792 if self._options.snapshot: | 791 if self._options.snapshot: |
793 config = self.DEFAULT_SNAPSHOT_FILE_TEXT % {'solution_list': new_gclient} | 792 config = self.DEFAULT_SNAPSHOT_FILE_TEXT % {'solution_list': new_gclient} |
794 snapclient = GClient(self._root_dir, self._options) | 793 snapclient = GClient(self._root_dir, self._options) |
795 snapclient.SetConfig(config) | 794 snapclient.SetConfig(config) |
796 print(snapclient._config_content) | 795 print(snapclient.config_content) |
797 | 796 |
798 | 797 |
799 #### gclient commands. | 798 #### gclient commands. |
800 | 799 |
801 | 800 |
802 def CMDcleanup(parser, args): | 801 def CMDcleanup(parser, args): |
803 """Cleans up all working copies. | 802 """Cleans up all working copies. |
804 | 803 |
805 Mostly svn-specific. Simply runs 'svn cleanup' for each module. | 804 Mostly svn-specific. Simply runs 'svn cleanup' for each module. |
806 """ | 805 """ |
807 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 806 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", |
808 help="override deps for the specified (comma-separated) " | 807 help="override deps for the specified (comma-separated) " |
809 "platform(s); 'all' will process all deps_os " | 808 "platform(s); 'all' will process all deps_os " |
810 "references") | 809 "references") |
811 (options, args) = parser.parse_args(args) | 810 (options, args) = parser.parse_args(args) |
812 client = GClient.LoadCurrentConfig(options) | 811 client = GClient.LoadCurrentConfig(options) |
813 if not client: | 812 if not client: |
814 raise gclient_utils.Error("client not configured; see 'gclient config'") | 813 raise gclient_utils.Error("client not configured; see 'gclient config'") |
815 if options.verbose: | 814 if options.verbose: |
816 # Print out the .gclient file. This is longer than if we just printed the | 815 # Print out the .gclient file. This is longer than if we just printed the |
817 # client dict, but more legible, and it might contain helpful comments. | 816 # client dict, but more legible, and it might contain helpful comments. |
818 print(client.ConfigContent()) | 817 print(client.config_content) |
819 return client.RunOnDeps('cleanup', args) | 818 return client.RunOnDeps('cleanup', args) |
820 | 819 |
821 | 820 |
822 @attr('usage', '[url] [safesync url]') | 821 @attr('usage', '[url] [safesync url]') |
823 def CMDconfig(parser, args): | 822 def CMDconfig(parser, args): |
824 """Create a .gclient file in the current directory. | 823 """Create a .gclient file in the current directory. |
825 | 824 |
826 This specifies the configuration for further commands. After update/sync, | 825 This specifies the configuration for further commands. After update/sync, |
827 top-level DEPS files in each module are read to determine dependent | 826 top-level DEPS files in each module are read to determine dependent |
828 modules to operate on as well. If optional [url] parameter is | 827 modules to operate on as well. If optional [url] parameter is |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
871 if len(args) != 1: | 870 if len(args) != 1: |
872 raise gclient_utils.Error("Need directory name") | 871 raise gclient_utils.Error("Need directory name") |
873 client = GClient.LoadCurrentConfig(options) | 872 client = GClient.LoadCurrentConfig(options) |
874 | 873 |
875 if not client: | 874 if not client: |
876 raise gclient_utils.Error("client not configured; see 'gclient config'") | 875 raise gclient_utils.Error("client not configured; see 'gclient config'") |
877 | 876 |
878 if options.verbose: | 877 if options.verbose: |
879 # Print out the .gclient file. This is longer than if we just printed the | 878 # Print out the .gclient file. This is longer than if we just printed the |
880 # client dict, but more legible, and it might contain helpful comments. | 879 # client dict, but more legible, and it might contain helpful comments. |
881 print(client.ConfigContent()) | 880 print(client.config_content) |
882 return client.RunOnDeps('export', args) | 881 return client.RunOnDeps('export', args) |
883 | 882 |
884 | 883 |
885 @attr('epilog', """Example: | 884 @attr('epilog', """Example: |
886 gclient pack > patch.txt | 885 gclient pack > patch.txt |
887 generate simple patch for configured client and dependences | 886 generate simple patch for configured client and dependences |
888 """) | 887 """) |
889 def CMDpack(parser, args): | 888 def CMDpack(parser, args): |
890 """Generate a patch which can be applied at the root of the tree. | 889 """Generate a patch which can be applied at the root of the tree. |
891 | 890 |
892 Internally, runs 'svn diff'/'git diff' on each checked out module and | 891 Internally, runs 'svn diff'/'git diff' on each checked out module and |
893 dependencies, and performs minimal postprocessing of the output. The | 892 dependencies, and performs minimal postprocessing of the output. The |
894 resulting patch is printed to stdout and can be applied to a freshly | 893 resulting patch is printed to stdout and can be applied to a freshly |
895 checked out tree via 'patch -p0 < patchfile'. | 894 checked out tree via 'patch -p0 < patchfile'. |
896 """ | 895 """ |
897 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 896 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", |
898 help="override deps for the specified (comma-separated) " | 897 help="override deps for the specified (comma-separated) " |
899 "platform(s); 'all' will process all deps_os " | 898 "platform(s); 'all' will process all deps_os " |
900 "references") | 899 "references") |
901 (options, args) = parser.parse_args(args) | 900 (options, args) = parser.parse_args(args) |
902 client = GClient.LoadCurrentConfig(options) | 901 client = GClient.LoadCurrentConfig(options) |
903 if not client: | 902 if not client: |
904 raise gclient_utils.Error("client not configured; see 'gclient config'") | 903 raise gclient_utils.Error("client not configured; see 'gclient config'") |
905 if options.verbose: | 904 if options.verbose: |
906 # Print out the .gclient file. This is longer than if we just printed the | 905 # Print out the .gclient file. This is longer than if we just printed the |
907 # client dict, but more legible, and it might contain helpful comments. | 906 # client dict, but more legible, and it might contain helpful comments. |
908 print(client.ConfigContent()) | 907 print(client.config_content) |
909 return client.RunOnDeps('pack', args) | 908 return client.RunOnDeps('pack', args) |
910 | 909 |
911 | 910 |
912 def CMDstatus(parser, args): | 911 def CMDstatus(parser, args): |
913 """Show modification status for every dependencies.""" | 912 """Show modification status for every dependencies.""" |
914 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 913 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", |
915 help="override deps for the specified (comma-separated) " | 914 help="override deps for the specified (comma-separated) " |
916 "platform(s); 'all' will process all deps_os " | 915 "platform(s); 'all' will process all deps_os " |
917 "references") | 916 "references") |
918 (options, args) = parser.parse_args(args) | 917 (options, args) = parser.parse_args(args) |
919 client = GClient.LoadCurrentConfig(options) | 918 client = GClient.LoadCurrentConfig(options) |
920 if not client: | 919 if not client: |
921 raise gclient_utils.Error("client not configured; see 'gclient config'") | 920 raise gclient_utils.Error("client not configured; see 'gclient config'") |
922 if options.verbose: | 921 if options.verbose: |
923 # Print out the .gclient file. This is longer than if we just printed the | 922 # Print out the .gclient file. This is longer than if we just printed the |
924 # client dict, but more legible, and it might contain helpful comments. | 923 # client dict, but more legible, and it might contain helpful comments. |
925 print(client.ConfigContent()) | 924 print(client.config_content) |
926 return client.RunOnDeps('status', args) | 925 return client.RunOnDeps('status', args) |
927 | 926 |
928 | 927 |
929 @attr('epilog', """Examples: | 928 @attr('epilog', """Examples: |
930 gclient sync | 929 gclient sync |
931 update files from SCM according to current configuration, | 930 update files from SCM according to current configuration, |
932 *for modules which have changed since last update or sync* | 931 *for modules which have changed since last update or sync* |
933 gclient sync --force | 932 gclient sync --force |
934 update files from SCM according to current configuration, for | 933 update files from SCM according to current configuration, for |
935 all modules (useful for recovering files deleted from local copy) | 934 all modules (useful for recovering files deleted from local copy) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 if not client: | 969 if not client: |
971 raise gclient_utils.Error("client not configured; see 'gclient config'") | 970 raise gclient_utils.Error("client not configured; see 'gclient config'") |
972 | 971 |
973 if options.revisions and options.head: | 972 if options.revisions and options.head: |
974 # TODO(maruel): Make it a parser.error if it doesn't break any builder. | 973 # TODO(maruel): Make it a parser.error if it doesn't break any builder. |
975 print("Warning: you cannot use both --head and --revision") | 974 print("Warning: you cannot use both --head and --revision") |
976 | 975 |
977 if options.verbose: | 976 if options.verbose: |
978 # Print out the .gclient file. This is longer than if we just printed the | 977 # Print out the .gclient file. This is longer than if we just printed the |
979 # client dict, but more legible, and it might contain helpful comments. | 978 # client dict, but more legible, and it might contain helpful comments. |
980 print(client.ConfigContent()) | 979 print(client.config_content) |
981 return client.RunOnDeps('update', args) | 980 return client.RunOnDeps('update', args) |
982 | 981 |
983 | 982 |
984 def CMDupdate(parser, args): | 983 def CMDupdate(parser, args): |
985 """Alias for the sync command. Deprecated.""" | 984 """Alias for the sync command. Deprecated.""" |
986 return CMDsync(parser, args) | 985 return CMDsync(parser, args) |
987 | 986 |
988 def CMDdiff(parser, args): | 987 def CMDdiff(parser, args): |
989 """Displays local diff for every dependencies.""" | 988 """Displays local diff for every dependencies.""" |
990 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 989 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", |
991 help="override deps for the specified (comma-separated) " | 990 help="override deps for the specified (comma-separated) " |
992 "platform(s); 'all' will process all deps_os " | 991 "platform(s); 'all' will process all deps_os " |
993 "references") | 992 "references") |
994 (options, args) = parser.parse_args(args) | 993 (options, args) = parser.parse_args(args) |
995 client = GClient.LoadCurrentConfig(options) | 994 client = GClient.LoadCurrentConfig(options) |
996 if not client: | 995 if not client: |
997 raise gclient_utils.Error("client not configured; see 'gclient config'") | 996 raise gclient_utils.Error("client not configured; see 'gclient config'") |
998 if options.verbose: | 997 if options.verbose: |
999 # Print out the .gclient file. This is longer than if we just printed the | 998 # Print out the .gclient file. This is longer than if we just printed the |
1000 # client dict, but more legible, and it might contain helpful comments. | 999 # client dict, but more legible, and it might contain helpful comments. |
1001 print(client.ConfigContent()) | 1000 print(client.config_content) |
1002 return client.RunOnDeps('diff', args) | 1001 return client.RunOnDeps('diff', args) |
1003 | 1002 |
1004 | 1003 |
1005 def CMDrevert(parser, args): | 1004 def CMDrevert(parser, args): |
1006 """Revert all modifications in every dependencies.""" | 1005 """Revert all modifications in every dependencies.""" |
1007 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 1006 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", |
1008 help="override deps for the specified (comma-separated) " | 1007 help="override deps for the specified (comma-separated) " |
1009 "platform(s); 'all' will process all deps_os " | 1008 "platform(s); 'all' will process all deps_os " |
1010 "references") | 1009 "references") |
1011 parser.add_option("-n", "--nohooks", action="store_true", | 1010 parser.add_option("-n", "--nohooks", action="store_true", |
(...skipping 15 matching lines...) Expand all Loading... |
1027 "references") | 1026 "references") |
1028 parser.add_option("-f", "--force", action="store_true", default=True, | 1027 parser.add_option("-f", "--force", action="store_true", default=True, |
1029 help="Deprecated. No effect.") | 1028 help="Deprecated. No effect.") |
1030 (options, args) = parser.parse_args(args) | 1029 (options, args) = parser.parse_args(args) |
1031 client = GClient.LoadCurrentConfig(options) | 1030 client = GClient.LoadCurrentConfig(options) |
1032 if not client: | 1031 if not client: |
1033 raise gclient_utils.Error("client not configured; see 'gclient config'") | 1032 raise gclient_utils.Error("client not configured; see 'gclient config'") |
1034 if options.verbose: | 1033 if options.verbose: |
1035 # Print out the .gclient file. This is longer than if we just printed the | 1034 # Print out the .gclient file. This is longer than if we just printed the |
1036 # client dict, but more legible, and it might contain helpful comments. | 1035 # client dict, but more legible, and it might contain helpful comments. |
1037 print(client.ConfigContent()) | 1036 print(client.config_content) |
1038 options.force = True | 1037 options.force = True |
1039 options.nohooks = False | 1038 options.nohooks = False |
1040 return client.RunOnDeps('runhooks', args) | 1039 return client.RunOnDeps('runhooks', args) |
1041 | 1040 |
1042 | 1041 |
1043 def CMDrevinfo(parser, args): | 1042 def CMDrevinfo(parser, args): |
1044 """Outputs details for every dependencies.""" | 1043 """Outputs details for every dependencies.""" |
1045 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", | 1044 parser.add_option("--deps", dest="deps_os", metavar="OS_LIST", |
1046 help="override deps for the specified (comma-separated) " | 1045 help="override deps for the specified (comma-separated) " |
1047 "platform(s); 'all' will process all deps_os " | 1046 "platform(s); 'all' will process all deps_os " |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 return CMDhelp(parser, argv) | 1126 return CMDhelp(parser, argv) |
1128 except gclient_utils.Error, e: | 1127 except gclient_utils.Error, e: |
1129 print >> sys.stderr, "Error: %s" % str(e) | 1128 print >> sys.stderr, "Error: %s" % str(e) |
1130 return 1 | 1129 return 1 |
1131 | 1130 |
1132 | 1131 |
1133 if "__main__" == __name__: | 1132 if "__main__" == __name__: |
1134 sys.exit(Main(sys.argv[1:])) | 1133 sys.exit(Main(sys.argv[1:])) |
1135 | 1134 |
1136 # vim: ts=2:sw=2:tw=80:et: | 1135 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |