| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 if self.parent: | 281 if self.parent: |
| 282 url = self.parent.get_custom_deps(name, url) | 282 url = self.parent.get_custom_deps(name, url) |
| 283 # None is a valid return value to disable a dependency. | 283 # None is a valid return value to disable a dependency. |
| 284 return self.custom_deps.get(name, url) | 284 return self.custom_deps.get(name, url) |
| 285 | 285 |
| 286 | 286 |
| 287 class Dependency(gclient_utils.WorkItem, DependencySettings): | 287 class Dependency(gclient_utils.WorkItem, DependencySettings): |
| 288 """Object that represents a dependency checkout.""" | 288 """Object that represents a dependency checkout.""" |
| 289 | 289 |
| 290 def __init__(self, parent, name, url, safesync_url, managed, custom_deps, | 290 def __init__(self, parent, name, url, safesync_url, managed, custom_deps, |
| 291 custom_vars, custom_hooks, deps_file, should_process): | 291 custom_vars, custom_hooks, deps_file, should_process, |
| 292 tmpdir_stage): |
| 292 gclient_utils.WorkItem.__init__(self, name) | 293 gclient_utils.WorkItem.__init__(self, name) |
| 293 DependencySettings.__init__( | 294 DependencySettings.__init__( |
| 294 self, parent, url, safesync_url, managed, custom_deps, custom_vars, | 295 self, parent, url, safesync_url, managed, custom_deps, custom_vars, |
| 295 custom_hooks, deps_file, should_process) | 296 custom_hooks, deps_file, should_process) |
| 296 | 297 |
| 297 # This is in both .gclient and DEPS files: | 298 # This is in both .gclient and DEPS files: |
| 298 self._deps_hooks = [] | 299 self._deps_hooks = [] |
| 299 | 300 |
| 300 # Calculates properties: | 301 # Calculates properties: |
| 301 self._parsed_url = None | 302 self._parsed_url = None |
| 302 self._dependencies = [] | 303 self._dependencies = [] |
| 303 # A cache of the files affected by the current operation, necessary for | 304 # A cache of the files affected by the current operation, necessary for |
| 304 # hooks. | 305 # hooks. |
| 305 self._file_list = [] | 306 self._file_list = [] |
| 306 # If it is not set to True, the dependency wasn't processed for its child | 307 # If it is not set to True, the dependency wasn't processed for its child |
| 307 # dependency, i.e. its DEPS wasn't read. | 308 # dependency, i.e. its DEPS wasn't read. |
| 308 self._deps_parsed = False | 309 self._deps_parsed = False |
| 309 # This dependency has been processed, i.e. checked out | 310 # This dependency has been processed, i.e. checked out |
| 310 self._processed = False | 311 self._processed = False |
| 311 # This dependency had its hook run | 312 # This dependency had its hook run |
| 312 self._hooks_ran = False | 313 self._hooks_ran = False |
| 313 # This is the scm used to checkout self.url. It may be used by dependencies | 314 # This is the scm used to checkout self.url. It may be used by dependencies |
| 314 # to get the datetime of the revision we checked out. | 315 # to get the datetime of the revision we checked out. |
| 315 self._used_scm = None | 316 self._used_scm = None |
| 317 self.tmpdir_stage = tmpdir_stage |
| 316 | 318 |
| 317 if not self.name and self.parent: | 319 if not self.name and self.parent: |
| 318 raise gclient_utils.Error('Dependency without name') | 320 raise gclient_utils.Error('Dependency without name') |
| 319 | 321 |
| 320 @property | 322 @property |
| 321 def requirements(self): | 323 def requirements(self): |
| 322 """Calculate the list of requirements.""" | 324 """Calculate the list of requirements.""" |
| 323 requirements = set() | 325 requirements = set() |
| 324 # self.parent is implicitly a requirement. This will be recursive by | 326 # self.parent is implicitly a requirement. This will be recursive by |
| 325 # definition. | 327 # definition. |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 deps = local_scope.get('deps', {}) | 495 deps = local_scope.get('deps', {}) |
| 494 if 'recursion' in local_scope: | 496 if 'recursion' in local_scope: |
| 495 self.recursion_override = local_scope.get('recursion') | 497 self.recursion_override = local_scope.get('recursion') |
| 496 logging.warning( | 498 logging.warning( |
| 497 'Setting %s recursion to %d.', self.name, self.recursion_limit) | 499 'Setting %s recursion to %d.', self.name, self.recursion_limit) |
| 498 # If present, save 'target_os' in the local_target_os property. | 500 # If present, save 'target_os' in the local_target_os property. |
| 499 if 'target_os' in local_scope: | 501 if 'target_os' in local_scope: |
| 500 self.local_target_os = local_scope['target_os'] | 502 self.local_target_os = local_scope['target_os'] |
| 501 # load os specific dependencies if defined. these dependencies may | 503 # load os specific dependencies if defined. these dependencies may |
| 502 # override or extend the values defined by the 'deps' member. | 504 # override or extend the values defined by the 'deps' member. |
| 505 |
| 506 tmpdir_staged_deps = local_scope.get('tmpdir_stage', []) |
| 503 target_os_deps = {} | 507 target_os_deps = {} |
| 504 if 'deps_os' in local_scope: | 508 if 'deps_os' in local_scope: |
| 505 for deps_os_key in self.target_os: | 509 for deps_os_key in self.target_os: |
| 506 os_deps = local_scope['deps_os'].get(deps_os_key, {}) | 510 os_deps = local_scope['deps_os'].get(deps_os_key, {}) |
| 507 if len(self.target_os) > 1: | 511 if len(self.target_os) > 1: |
| 508 # Ignore any conflict when including deps for more than one | 512 # Ignore any conflict when including deps for more than one |
| 509 # platform, so we collect the broadest set of dependencies | 513 # platform, so we collect the broadest set of dependencies |
| 510 # available. We may end up with the wrong revision of something for | 514 # available. We may end up with the wrong revision of something for |
| 511 # our platform, but this is the best we can do. | 515 # our platform, but this is the best we can do. |
| 512 target_os_deps.update( | 516 target_os_deps.update( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 534 # dependency local path. | 538 # dependency local path. |
| 535 rel_deps[os.path.normpath(os.path.join(self.name, d))] = url | 539 rel_deps[os.path.normpath(os.path.join(self.name, d))] = url |
| 536 deps = rel_deps | 540 deps = rel_deps |
| 537 | 541 |
| 538 # Convert the deps into real Dependency. | 542 # Convert the deps into real Dependency. |
| 539 deps_to_add = [] | 543 deps_to_add = [] |
| 540 for name, url in deps.iteritems(): | 544 for name, url in deps.iteritems(): |
| 541 should_process = self.recursion_limit and self.should_process | 545 should_process = self.recursion_limit and self.should_process |
| 542 deps_to_add.append(Dependency( | 546 deps_to_add.append(Dependency( |
| 543 self, name, url, None, None, None, None, None, | 547 self, name, url, None, None, None, None, None, |
| 544 self.deps_file, should_process)) | 548 self.deps_file, should_process, name in tmpdir_staged_deps)) |
| 545 deps_to_add.sort(key=lambda x: x.name) | 549 deps_to_add.sort(key=lambda x: x.name) |
| 546 | 550 |
| 547 # override named sets of hooks by the custom hooks | 551 # override named sets of hooks by the custom hooks |
| 548 hooks_to_run = [] | 552 hooks_to_run = [] |
| 549 hook_names_to_suppress = [c.get('name', '') for c in self.custom_hooks] | 553 hook_names_to_suppress = [c.get('name', '') for c in self.custom_hooks] |
| 550 for hook in local_scope.get('hooks', []): | 554 for hook in local_scope.get('hooks', []): |
| 551 if hook.get('name', '') not in hook_names_to_suppress: | 555 if hook.get('name', '') not in hook_names_to_suppress: |
| 552 hooks_to_run.append(hook) | 556 hooks_to_run.append(hook) |
| 553 | 557 |
| 554 # add the replacements and any additions | 558 # add the replacements and any additions |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 # pylint: disable=E1103 | 629 # pylint: disable=E1103 |
| 626 options.revision = parsed_url.GetRevision() | 630 options.revision = parsed_url.GetRevision() |
| 627 self._used_scm = gclient_scm.SVNWrapper( | 631 self._used_scm = gclient_scm.SVNWrapper( |
| 628 parsed_url.GetPath(), self.root.root_dir, self.name) | 632 parsed_url.GetPath(), self.root.root_dir, self.name) |
| 629 self._used_scm.RunCommand('updatesingle', | 633 self._used_scm.RunCommand('updatesingle', |
| 630 options, args + [parsed_url.GetFilename()], file_list) | 634 options, args + [parsed_url.GetFilename()], file_list) |
| 631 else: | 635 else: |
| 632 # Create a shallow copy to mutate revision. | 636 # Create a shallow copy to mutate revision. |
| 633 options = copy.copy(options) | 637 options = copy.copy(options) |
| 634 options.revision = revision_overrides.get(self.name) | 638 options.revision = revision_overrides.get(self.name) |
| 639 options.stage_clone = self.tmpdir_stage |
| 635 self.maybeGetParentRevision( | 640 self.maybeGetParentRevision( |
| 636 command, options, parsed_url, self.parent.name, revision_overrides) | 641 command, options, parsed_url, self.parent.name, revision_overrides) |
| 637 self._used_scm = gclient_scm.CreateSCM( | 642 self._used_scm = gclient_scm.CreateSCM( |
| 638 parsed_url, self.root.root_dir, self.name) | 643 parsed_url, self.root.root_dir, self.name) |
| 639 self._used_scm.RunCommand(command, options, args, file_list) | 644 self._used_scm.RunCommand(command, options, args, file_list) |
| 640 if file_list: | 645 if file_list: |
| 641 file_list = [os.path.join(self.name, f.strip()) for f in file_list] | 646 file_list = [os.path.join(self.name, f.strip()) for f in file_list] |
| 642 | 647 |
| 643 # TODO(phajdan.jr): We should know exactly when the paths are absolute. | 648 # TODO(phajdan.jr): We should know exactly when the paths are absolute. |
| 644 # Convert all absolute paths to relative. | 649 # Convert all absolute paths to relative. |
| (...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1854 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1850 print >> sys.stderr, 'Error: %s' % str(e) | 1855 print >> sys.stderr, 'Error: %s' % str(e) |
| 1851 return 1 | 1856 return 1 |
| 1852 | 1857 |
| 1853 | 1858 |
| 1854 if '__main__' == __name__: | 1859 if '__main__' == __name__: |
| 1855 fix_encoding.fix_encoding() | 1860 fix_encoding.fix_encoding() |
| 1856 sys.exit(Main(sys.argv[1:])) | 1861 sys.exit(Main(sys.argv[1:])) |
| 1857 | 1862 |
| 1858 # vim: ts=2:sw=2:tw=80:et: | 1863 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |