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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 number or a git hash. A git branch name isn't "pinned" since the actual | 713 number or a git hash. A git branch name isn't "pinned" since the actual |
714 commit can change. | 714 commit can change. |
715 | 715 |
716 The --snapshot option allows creating a .gclient file to reproduce the tree. | 716 The --snapshot option allows creating a .gclient file to reproduce the tree. |
717 """ | 717 """ |
718 if not self.dependencies: | 718 if not self.dependencies: |
719 raise gclient_utils.Error('No solution specified') | 719 raise gclient_utils.Error('No solution specified') |
720 | 720 |
721 # Inner helper to generate base url and rev tuple | 721 # Inner helper to generate base url and rev tuple |
722 def GetURLAndRev(name, original_url): | 722 def GetURLAndRev(name, original_url): |
| 723 if not original_url: |
| 724 return None |
723 url, _ = gclient_utils.SplitUrlRevision(original_url) | 725 url, _ = gclient_utils.SplitUrlRevision(original_url) |
724 scm = gclient_scm.CreateSCM(original_url, self.root_dir(), name) | 726 scm = gclient_scm.CreateSCM(original_url, self.root_dir(), name) |
725 return (url, scm.revinfo(self._options, [], None)) | 727 return '%s@%s' % (url, scm.revinfo(self._options, [], None)) |
726 | 728 |
727 # text of the snapshot gclient file | 729 # text of the snapshot gclient file |
728 new_gclient = "" | 730 new_gclient = "" |
729 # Dictionary of { path : SCM url } to ensure no duplicate solutions | 731 # Dictionary of { path : SCM url } to ensure no duplicate solutions |
730 solution_names = {} | 732 solution_names = {} |
731 entries = {} | 733 entries = {} |
732 # Run on the base solutions first. | 734 # Run on the base solutions first. |
733 for solution in self.dependencies: | 735 for solution in self.dependencies: |
734 # Dictionary of { path : SCM url } to describe the gclient checkout | 736 # Dictionary of { path : SCM url } to describe the gclient checkout |
735 name = solution.name | 737 name = solution.name |
736 if name in solution_names: | 738 if name in solution_names: |
737 raise gclient_utils.Error("solution %s specified more than once" % name) | 739 raise gclient_utils.Error("solution %s specified more than once" % name) |
738 (url, rev) = GetURLAndRev(name, solution.url) | 740 url = GetURLAndRev(name, solution.url) |
739 entries[name] = "%s@%s" % (url, rev) | 741 entries[name] = url |
740 solution_names[name] = "%s@%s" % (url, rev) | 742 solution_names[name] = url |
741 | 743 |
742 # Process the dependencies next (sort alphanumerically to ensure that | 744 # Process the dependencies next (sort alphanumerically to ensure that |
743 # containing directories get populated first and for readability) | 745 # containing directories get populated first and for readability) |
744 deps = self._ParseAllDeps(entries) | 746 deps = self._ParseAllDeps(entries) |
745 deps_to_process = deps.keys() | 747 deps_to_process = deps.keys() |
746 deps_to_process.sort() | 748 deps_to_process.sort() |
747 | 749 |
748 # First pass for direct dependencies. | 750 # First pass for direct dependencies. |
749 for d in deps_to_process: | 751 for d in deps_to_process: |
750 if type(deps[d]) == str: | 752 if type(deps[d]) == str: |
751 (url, rev) = GetURLAndRev(d, deps[d]) | 753 entries[d] = GetURLAndRev(d, deps[d]) |
752 entries[d] = "%s@%s" % (url, rev) | |
753 elif isinstance(deps[d], self.FileImpl): | 754 elif isinstance(deps[d], self.FileImpl): |
754 (url, rev) = GetURLAndRev(d, deps[d].file_location) | 755 entries[d] = GetURLAndRev(d, deps[d].file_location) |
755 entries[d] = "%s@%s" % (url, rev) | |
756 | 756 |
757 # Second pass for inherited deps (via the From keyword) | 757 # Second pass for inherited deps (via the From keyword) |
758 for d in deps_to_process: | 758 for d in deps_to_process: |
759 if isinstance(deps[d], self.FromImpl): | 759 if isinstance(deps[d], self.FromImpl): |
760 deps_parent_url = entries[deps[d].module_name] | 760 deps_parent_url = entries[deps[d].module_name] |
761 if deps_parent_url.find("@") < 0: | 761 if deps_parent_url.find("@") < 0: |
762 raise gclient_utils.Error("From %s missing revisioned url" % | 762 raise gclient_utils.Error("From %s missing revisioned url" % |
763 deps[d].module_name) | 763 deps[d].module_name) |
764 sub_deps_base_url = deps[deps[d].module_name] | 764 sub_deps_base_url = deps[deps[d].module_name] |
765 sub_deps = Dependency(self, deps[d].module_name, sub_deps_base_url | 765 sub_deps = Dependency(self, deps[d].module_name, sub_deps_base_url |
766 ).ParseDepsFile(False) | 766 ).ParseDepsFile(False) |
767 url = deps[d].GetUrl(d, sub_deps_base_url, self.root_dir(), sub_deps) | 767 url = deps[d].GetUrl(d, sub_deps_base_url, self.root_dir(), sub_deps) |
768 (url, rev) = GetURLAndRev(d, url) | 768 entries[d] = GetURLAndRev(d, url) |
769 entries[d] = "%s@%s" % (url, rev) | |
770 | 769 |
771 # Build the snapshot configuration string | 770 # Build the snapshot configuration string |
772 if self._options.snapshot: | 771 if self._options.snapshot: |
| 772 url = entries.pop(name) |
| 773 |
| 774 # Build the snapshot configuration string |
| 775 if self._options.snapshot: |
773 url = entries.pop(name) | 776 url = entries.pop(name) |
774 custom_deps = ''.join([' \"%s\": \"%s\",\n' % (x, entries[x]) | 777 custom_deps = ''.join([' \"%s\": \"%s\",\n' % (x, entries[x]) |
775 for x in sorted(entries.keys())]) | 778 for x in sorted(entries.keys())]) |
776 | 779 |
777 new_gclient += self.DEFAULT_SNAPSHOT_SOLUTION_TEXT % { | 780 new_gclient += self.DEFAULT_SNAPSHOT_SOLUTION_TEXT % { |
778 'solution_name': name, | 781 'solution_name': name, |
779 'solution_url': url, | 782 'solution_url': url, |
780 'safesync_url' : '', | 783 'safesync_url' : '', |
781 'solution_deps': custom_deps, | 784 'solution_deps': custom_deps, |
782 } | 785 } |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 return CMDhelp(parser, argv) | 1205 return CMDhelp(parser, argv) |
1203 except gclient_utils.Error, e: | 1206 except gclient_utils.Error, e: |
1204 print >> sys.stderr, 'Error: %s' % str(e) | 1207 print >> sys.stderr, 'Error: %s' % str(e) |
1205 return 1 | 1208 return 1 |
1206 | 1209 |
1207 | 1210 |
1208 if '__main__' == __name__: | 1211 if '__main__' == __name__: |
1209 sys.exit(Main(sys.argv[1:])) | 1212 sys.exit(Main(sys.argv[1:])) |
1210 | 1213 |
1211 # vim: ts=2:sw=2:tw=80:et: | 1214 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |