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 """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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 self.deps_file = deps_file or self.DEPS_FILE | 153 self.deps_file = deps_file or self.DEPS_FILE |
154 # A cache of the files affected by the current operation, necessary for | 154 # A cache of the files affected by the current operation, necessary for |
155 # hooks. | 155 # hooks. |
156 self.file_list = [] | 156 self.file_list = [] |
157 self.deps_parsed = False | 157 self.deps_parsed = False |
158 self.direct_reference = False | 158 self.direct_reference = False |
159 | 159 |
160 # Sanity checks | 160 # Sanity checks |
161 if not self.name and self.parent: | 161 if not self.name and self.parent: |
162 raise gclient_utils.Error('Dependency without name') | 162 raise gclient_utils.Error('Dependency without name') |
163 if self.name in [d.name for d in self.tree(False)]: | 163 tree = dict((d.name, d) for d in self.tree(False)) |
164 raise gclient_utils.Error('Dependency %s specified more than once' % | 164 if self.name in tree: |
165 self.name) | 165 raise gclient_utils.Error( |
166 'Dependency %s specified more than once:\n %s\nvs\n %s' % | |
167 (self.name, tree[self.name].hierarchy(), self.hierarchy())) | |
166 if not isinstance(self.url, | 168 if not isinstance(self.url, |
167 (basestring, self.FromImpl, self.FileImpl, None.__class__)): | 169 (basestring, self.FromImpl, self.FileImpl, None.__class__)): |
168 raise gclient_utils.Error('dependency url must be either a string, None, ' | 170 raise gclient_utils.Error('dependency url must be either a string, None, ' |
169 'File() or From() instead of %s' % | 171 'File() or From() instead of %s' % |
170 self.url.__class__.__name__) | 172 self.url.__class__.__name__) |
171 if '/' in self.deps_file or '\\' in self.deps_file: | 173 if '/' in self.deps_file or '\\' in self.deps_file: |
172 raise gclient_utils.Error('deps_file name must not be a path, just a ' | 174 raise gclient_utils.Error('deps_file name must not be a path, just a ' |
173 'filename. %s' % self.deps_file) | 175 'filename. %s' % self.deps_file) |
174 | 176 |
175 def LateOverride(self, url): | 177 def LateOverride(self, url): |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 out.append('%s: %s' % (i, self.__dict__[i])) | 431 out.append('%s: %s' % (i, self.__dict__[i])) |
430 | 432 |
431 for d in self.dependencies: | 433 for d in self.dependencies: |
432 out.extend([' ' + x for x in str(d).splitlines()]) | 434 out.extend([' ' + x for x in str(d).splitlines()]) |
433 out.append('') | 435 out.append('') |
434 return '\n'.join(out) | 436 return '\n'.join(out) |
435 | 437 |
436 def __repr__(self): | 438 def __repr__(self): |
437 return '%s: %s' % (self.name, self.url) | 439 return '%s: %s' % (self.name, self.url) |
438 | 440 |
441 def hierarchy(self): | |
442 "Returns a human-readable hierarchical reference to a Dependency." | |
bradn
2010/07/22 21:22:25
Uh you'll want a """ here I believe.
| |
443 out = '%s(%s)' % (self.name, self.url) | |
444 i = self.parent | |
445 while i and i.name: | |
446 out = '%s(%s) -> %s' % (i.name, i.url, out) | |
447 i = i.parent | |
448 return out | |
449 | |
439 | 450 |
440 class GClient(Dependency): | 451 class GClient(Dependency): |
441 """Object that represent a gclient checkout. A tree of Dependency(), one per | 452 """Object that represent a gclient checkout. A tree of Dependency(), one per |
442 solution or DEPS entry.""" | 453 solution or DEPS entry.""" |
443 | 454 |
444 DEPS_OS_CHOICES = { | 455 DEPS_OS_CHOICES = { |
445 "win32": "win", | 456 "win32": "win", |
446 "win": "win", | 457 "win": "win", |
447 "cygwin": "win", | 458 "cygwin": "win", |
448 "darwin": "mac", | 459 "darwin": "mac", |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 return CMDhelp(parser, argv) | 1143 return CMDhelp(parser, argv) |
1133 except gclient_utils.Error, e: | 1144 except gclient_utils.Error, e: |
1134 print >> sys.stderr, 'Error: %s' % str(e) | 1145 print >> sys.stderr, 'Error: %s' % str(e) |
1135 return 1 | 1146 return 1 |
1136 | 1147 |
1137 | 1148 |
1138 if '__main__' == __name__: | 1149 if '__main__' == __name__: |
1139 sys.exit(Main(sys.argv[1:])) | 1150 sys.exit(Main(sys.argv[1:])) |
1140 | 1151 |
1141 # vim: ts=2:sw=2:tw=80:et: | 1152 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |