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 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 """Runs |command| then parse the DEPS file.""" | 584 """Runs |command| then parse the DEPS file.""" |
585 logging.info('Dependency(%s).run()' % self.name) | 585 logging.info('Dependency(%s).run()' % self.name) |
586 assert self._file_list == [] | 586 assert self._file_list == [] |
587 if not self.should_process: | 587 if not self.should_process: |
588 return | 588 return |
589 # When running runhooks, there's no need to consult the SCM. | 589 # When running runhooks, there's no need to consult the SCM. |
590 # All known hooks are expected to run unconditionally regardless of working | 590 # All known hooks are expected to run unconditionally regardless of working |
591 # copy state, so skip the SCM status check. | 591 # copy state, so skip the SCM status check. |
592 run_scm = command not in ('runhooks', 'recurse', None) | 592 run_scm = command not in ('runhooks', 'recurse', None) |
593 parsed_url = self.LateOverride(self.url) | 593 parsed_url = self.LateOverride(self.url) |
594 file_list = [] | 594 file_list = [] if not options.nohooks else None |
595 if run_scm and parsed_url: | 595 if run_scm and parsed_url: |
596 if isinstance(parsed_url, self.FileImpl): | 596 if isinstance(parsed_url, self.FileImpl): |
597 # Special support for single-file checkout. | 597 # Special support for single-file checkout. |
598 if not command in (None, 'cleanup', 'diff', 'pack', 'status'): | 598 if not command in (None, 'cleanup', 'diff', 'pack', 'status'): |
599 # Sadly, pylint doesn't realize that parsed_url is of FileImpl. | 599 # Sadly, pylint doesn't realize that parsed_url is of FileImpl. |
600 # pylint: disable=E1103 | 600 # pylint: disable=E1103 |
601 options.revision = parsed_url.GetRevision() | 601 options.revision = parsed_url.GetRevision() |
602 self._used_scm = gclient_scm.SVNWrapper( | 602 self._used_scm = gclient_scm.SVNWrapper( |
603 parsed_url.GetPath(), self.root.root_dir, self.name) | 603 parsed_url.GetPath(), self.root.root_dir, self.name) |
604 self._used_scm.RunCommand('updatesingle', | 604 self._used_scm.RunCommand('updatesingle', |
605 options, args + [parsed_url.GetFilename()], file_list) | 605 options, args + [parsed_url.GetFilename()], file_list) |
606 else: | 606 else: |
607 # Create a shallow copy to mutate revision. | 607 # Create a shallow copy to mutate revision. |
608 options = copy.copy(options) | 608 options = copy.copy(options) |
609 options.revision = revision_overrides.get(self.name) | 609 options.revision = revision_overrides.get(self.name) |
610 self.maybeGetParentRevision( | 610 self.maybeGetParentRevision( |
611 command, options, parsed_url, self.parent.name, revision_overrides) | 611 command, options, parsed_url, self.parent.name, revision_overrides) |
612 self._used_scm = gclient_scm.CreateSCM( | 612 self._used_scm = gclient_scm.CreateSCM( |
613 parsed_url, self.root.root_dir, self.name) | 613 parsed_url, self.root.root_dir, self.name) |
614 self._used_scm.RunCommand(command, options, args, file_list) | 614 self._used_scm.RunCommand(command, options, args, file_list) |
615 file_list = [os.path.join(self.name, f.strip()) for f in file_list] | 615 if file_list: |
| 616 file_list = [os.path.join(self.name, f.strip()) for f in file_list] |
616 | 617 |
617 # TODO(phajdan.jr): We should know exactly when the paths are absolute. | 618 # TODO(phajdan.jr): We should know exactly when the paths are absolute. |
618 # Convert all absolute paths to relative. | 619 # Convert all absolute paths to relative. |
619 for i in range(len(file_list)): | 620 for i in range(len(file_list or [])): |
620 # It depends on the command being executed (like runhooks vs sync). | 621 # It depends on the command being executed (like runhooks vs sync). |
621 if not os.path.isabs(file_list[i]): | 622 if not os.path.isabs(file_list[i]): |
622 continue | 623 continue |
623 prefix = os.path.commonprefix( | 624 prefix = os.path.commonprefix( |
624 [self.root.root_dir.lower(), file_list[i].lower()]) | 625 [self.root.root_dir.lower(), file_list[i].lower()]) |
625 file_list[i] = file_list[i][len(prefix):] | 626 file_list[i] = file_list[i][len(prefix):] |
626 # Strip any leading path separators. | 627 # Strip any leading path separators. |
627 while file_list[i].startswith(('\\', '/')): | 628 while file_list[i].startswith(('\\', '/')): |
628 file_list[i] = file_list[i][1:] | 629 file_list[i] = file_list[i][1:] |
629 | 630 |
630 # Always parse the DEPS file. | 631 # Always parse the DEPS file. |
631 self.ParseDepsFile() | 632 self.ParseDepsFile() |
632 | 633 |
633 self._run_is_done(file_list, parsed_url) | 634 self._run_is_done(file_list or [], parsed_url) |
634 | 635 |
635 if self.recursion_limit: | 636 if self.recursion_limit: |
636 # Parse the dependencies of this dependency. | 637 # Parse the dependencies of this dependency. |
637 for s in self.dependencies: | 638 for s in self.dependencies: |
638 work_queue.enqueue(s) | 639 work_queue.enqueue(s) |
639 | 640 |
640 if command == 'recurse': | 641 if command == 'recurse': |
641 if not isinstance(parsed_url, self.FileImpl): | 642 if not isinstance(parsed_url, self.FileImpl): |
642 # Skip file only checkout. | 643 # Skip file only checkout. |
643 scm = gclient_scm.GetScmName(parsed_url) | 644 scm = gclient_scm.GetScmName(parsed_url) |
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1816 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1817 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1817 print >> sys.stderr, 'Error: %s' % str(e) | 1818 print >> sys.stderr, 'Error: %s' % str(e) |
1818 return 1 | 1819 return 1 |
1819 | 1820 |
1820 | 1821 |
1821 if '__main__' == __name__: | 1822 if '__main__' == __name__: |
1822 fix_encoding.fix_encoding() | 1823 fix_encoding.fix_encoding() |
1823 sys.exit(Main(sys.argv[1:])) | 1824 sys.exit(Main(sys.argv[1:])) |
1824 | 1825 |
1825 # vim: ts=2:sw=2:tw=80:et: | 1826 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |