| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 self._processed = False | 257 self._processed = False |
| 258 # This dependency had its hook run | 258 # This dependency had its hook run |
| 259 self._hooks_ran = False | 259 self._hooks_ran = False |
| 260 | 260 |
| 261 # Setup self.requirements and find any other dependency who would have self | 261 # Setup self.requirements and find any other dependency who would have self |
| 262 # as a requirement. | 262 # as a requirement. |
| 263 | 263 |
| 264 # self.parent is implicitly a requirement. This will be recursive by | 264 # self.parent is implicitly a requirement. This will be recursive by |
| 265 # definition. | 265 # definition. |
| 266 if self.parent and self.parent.name: | 266 if self.parent and self.parent.name: |
| 267 self._requirements.add(self.parent.name) | 267 self.add_requirement(self.parent.name) |
| 268 | 268 |
| 269 # For a tree with at least 2 levels*, the leaf node needs to depend | 269 # For a tree with at least 2 levels*, the leaf node needs to depend |
| 270 # on the level higher up in an orderly way. | 270 # on the level higher up in an orderly way. |
| 271 # This becomes messy for >2 depth as the DEPS file format is a dictionary, | 271 # This becomes messy for >2 depth as the DEPS file format is a dictionary, |
| 272 # thus unsorted, while the .gclient format is a list thus sorted. | 272 # thus unsorted, while the .gclient format is a list thus sorted. |
| 273 # | 273 # |
| 274 # * _recursion_limit is hard coded 2 and there is no hope to change this | 274 # * _recursion_limit is hard coded 2 and there is no hope to change this |
| 275 # value. | 275 # value. |
| 276 # | 276 # |
| 277 # Interestingly enough, the following condition only works in the case we | 277 # Interestingly enough, the following condition only works in the case we |
| 278 # want: self is a 2nd level node. 3nd level node wouldn't need this since | 278 # want: self is a 2nd level node. 3nd level node wouldn't need this since |
| 279 # they already have their parent as a requirement. | 279 # they already have their parent as a requirement. |
| 280 root_deps = self.root.dependencies | 280 root_deps = self.root.dependencies |
| 281 if self.parent in root_deps: | 281 if self.parent in root_deps: |
| 282 for i in root_deps: | 282 for i in root_deps: |
| 283 if i is self.parent: | 283 if i is self.parent: |
| 284 break | 284 break |
| 285 if i.name: | 285 if i.name: |
| 286 self._requirements.add(i.name) | 286 self.add_requirement(i.name) |
| 287 | 287 |
| 288 if isinstance(self.url, self.FromImpl): | 288 if isinstance(self.url, self.FromImpl): |
| 289 self._requirements.add(self.url.module_name) | 289 self.add_requirement(self.url.module_name) |
| 290 | 290 |
| 291 if self.name and self.should_process: | 291 if self.name and self.should_process: |
| 292 for obj in self.root.depth_first_tree(): | 292 for obj in self.root.depth_first_tree(): |
| 293 if obj is self or not obj.name: | 293 if obj is self or not obj.name: |
| 294 continue | 294 continue |
| 295 # Step 1: Find any requirements self may need. | 295 # Step 1: Find any requirements self may need. |
| 296 if self.name.startswith(posixpath.join(obj.name, '')): | 296 if self.name.startswith(posixpath.join(obj.name, '')): |
| 297 self._requirements.add(obj.name) | 297 self.add_requirement(obj.name) |
| 298 # Step 2: Find any requirements self may impose. | 298 # Step 2: Find any requirements self may impose. |
| 299 if obj.name.startswith(posixpath.join(self.name, '')): | 299 if obj.name.startswith(posixpath.join(self.name, '')): |
| 300 try: | 300 obj.add_requirement(self.name) |
| 301 # Access to a protected member _requirements of a client class | |
| 302 # pylint: disable=W0212 | |
| 303 obj.lock.acquire() | |
| 304 obj._requirements.add(self.name) | |
| 305 finally: | |
| 306 obj.lock.release() | |
| 307 | 301 |
| 308 if not self.name and self.parent: | 302 if not self.name and self.parent: |
| 309 raise gclient_utils.Error('Dependency without name') | 303 raise gclient_utils.Error('Dependency without name') |
| 310 | 304 |
| 311 def LateOverride(self, url): | 305 def LateOverride(self, url): |
| 312 """Resolves the parsed url from url. | 306 """Resolves the parsed url from url. |
| 313 | 307 |
| 314 Manages From() keyword accordingly. Do not touch self.parsed_url nor | 308 Manages From() keyword accordingly. Do not touch self.parsed_url nor |
| 315 self.url because it may called with other urls due to From().""" | 309 self.url because it may called with other urls due to From().""" |
| 316 assert self.parsed_url == None or not self.should_process, self.parsed_url | 310 assert self.parsed_url == None or not self.should_process, self.parsed_url |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1453 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1447 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1454 print >> sys.stderr, 'Error: %s' % str(e) | 1448 print >> sys.stderr, 'Error: %s' % str(e) |
| 1455 return 1 | 1449 return 1 |
| 1456 | 1450 |
| 1457 | 1451 |
| 1458 if '__main__' == __name__: | 1452 if '__main__' == __name__: |
| 1459 fix_encoding.fix_encoding() | 1453 fix_encoding.fix_encoding() |
| 1460 sys.exit(Main(sys.argv[1:])) | 1454 sys.exit(Main(sys.argv[1:])) |
| 1461 | 1455 |
| 1462 # vim: ts=2:sw=2:tw=80:et: | 1456 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |