OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright 2008 Google Inc. All Rights Reserved. | 3 # Copyright 2008 Google Inc. All Rights Reserved. |
4 # | 4 # |
5 # Licensed under the Apache License, Version 2.0 (the "License"); | 5 # Licensed under the Apache License, Version 2.0 (the "License"); |
6 # you may not use this file except in compliance with the License. | 6 # you may not use this file except in compliance with the License. |
7 # You may obtain a copy of the License at | 7 # You may obtain a copy of the License at |
8 # | 8 # |
9 # http://www.apache.org/licenses/LICENSE-2.0 | 9 # http://www.apache.org/licenses/LICENSE-2.0 |
10 # | 10 # |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 __author__ = "darinf@gmail.com (Darin Fisher)" | 68 __author__ = "darinf@gmail.com (Darin Fisher)" |
69 __version__ = "0.3.3" | 69 __version__ = "0.3.3" |
70 | 70 |
71 import errno | 71 import errno |
72 import optparse | 72 import optparse |
73 import os | 73 import os |
74 import re | 74 import re |
75 import stat | 75 import stat |
76 import sys | 76 import sys |
77 import time | |
78 import urlparse | 77 import urlparse |
79 import urllib | 78 import urllib |
80 | 79 |
81 import gclient_scm | 80 import gclient_scm |
82 import gclient_utils | 81 import gclient_utils |
83 from gclient_utils import Error, FileRead, FileWrite | 82 from gclient_utils import Error, FileRead, FileWrite |
84 | 83 |
85 # default help text | 84 # default help text |
86 DEFAULT_USAGE_TEXT = ( | 85 DEFAULT_USAGE_TEXT = ( |
87 """usage: %prog <subcommand> [options] [--] [svn options/args...] | 86 """usage: %prog <subcommand> [options] [--] [svn options/args...] |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 # Only delete the directory if there are no changes in it, and | 741 # Only delete the directory if there are no changes in it, and |
743 # delete_unversioned_trees is set to true. | 742 # delete_unversioned_trees is set to true. |
744 prev_entries = self._ReadEntries() | 743 prev_entries = self._ReadEntries() |
745 for entry in prev_entries: | 744 for entry in prev_entries: |
746 # Fix path separator on Windows. | 745 # Fix path separator on Windows. |
747 entry_fixed = entry.replace('/', os.path.sep) | 746 entry_fixed = entry.replace('/', os.path.sep) |
748 e_dir = os.path.join(self._root_dir, entry_fixed) | 747 e_dir = os.path.join(self._root_dir, entry_fixed) |
749 # Use entry and not entry_fixed there. | 748 # Use entry and not entry_fixed there. |
750 if entry not in entries and os.path.exists(e_dir): | 749 if entry not in entries and os.path.exists(e_dir): |
751 if not self._options.delete_unversioned_trees or \ | 750 if not self._options.delete_unversioned_trees or \ |
752 CaptureSVNStatus(e_dir): | 751 gclient_scm.CaptureSVNStatus(e_dir): |
753 # There are modified files in this entry. Keep warning until | 752 # There are modified files in this entry. Keep warning until |
754 # removed. | 753 # removed. |
755 entries[entry] = None | 754 entries[entry] = None |
756 print(("\nWARNING: \"%s\" is no longer part of this client. " | 755 print(("\nWARNING: \"%s\" is no longer part of this client. " |
757 "It is recommended that you manually remove it.\n") % | 756 "It is recommended that you manually remove it.\n") % |
758 entry_fixed) | 757 entry_fixed) |
759 else: | 758 else: |
760 # Delete the entry | 759 # Delete the entry |
761 print("\n________ deleting \'%s\' " + | 760 print("\n________ deleting \'%s\' " + |
762 "in \'%s\'") % (entry_fixed, self._root_dir) | 761 "in \'%s\'") % (entry_fixed, self._root_dir) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 entries_deps_content = {} | 800 entries_deps_content = {} |
802 | 801 |
803 # Inner helper to generate base url and rev tuple (including honoring | 802 # Inner helper to generate base url and rev tuple (including honoring |
804 # |revision_overrides|) | 803 # |revision_overrides|) |
805 def GetURLAndRev(name, original_url): | 804 def GetURLAndRev(name, original_url): |
806 if original_url.find("@") < 0: | 805 if original_url.find("@") < 0: |
807 if revision_overrides.has_key(name): | 806 if revision_overrides.has_key(name): |
808 return (original_url, int(revision_overrides[name])) | 807 return (original_url, int(revision_overrides[name])) |
809 else: | 808 else: |
810 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 809 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
811 return (original_url, CaptureSVNHeadRevision(original_url)) | 810 return (original_url, |
| 811 gclient_scm.CaptureSVNHeadRevision(original_url)) |
812 else: | 812 else: |
813 url_components = original_url.split("@") | 813 url_components = original_url.split("@") |
814 if revision_overrides.has_key(name): | 814 if revision_overrides.has_key(name): |
815 return (url_components[0], int(revision_overrides[name])) | 815 return (url_components[0], int(revision_overrides[name])) |
816 else: | 816 else: |
817 return (url_components[0], int(url_components[1])) | 817 return (url_components[0], int(url_components[1])) |
818 | 818 |
819 # Run on the base solutions first. | 819 # Run on the base solutions first. |
820 for solution in solutions: | 820 for solution in solutions: |
821 name = solution["name"] | 821 name = solution["name"] |
822 if name in entries: | 822 if name in entries: |
823 raise Error("solution %s specified more than once" % name) | 823 raise Error("solution %s specified more than once" % name) |
824 (url, rev) = GetURLAndRev(name, solution["url"]) | 824 (url, rev) = GetURLAndRev(name, solution["url"]) |
825 entries[name] = "%s@%d" % (url, rev) | 825 entries[name] = "%s@%d" % (url, rev) |
826 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 826 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
827 entries_deps_content[name] = CaptureSVN( | 827 entries_deps_content[name] = gclient_scm.CaptureSVN( |
828 ["cat", | 828 ["cat", |
829 "%s/%s@%d" % (url, | 829 "%s/%s@%d" % (url, |
830 self._options.deps_file, | 830 self._options.deps_file, |
831 rev)], | 831 rev)], |
832 os.getcwd()) | 832 os.getcwd()) |
833 | 833 |
834 # Process the dependencies next (sort alphanumerically to ensure that | 834 # Process the dependencies next (sort alphanumerically to ensure that |
835 # containing directories get populated first and for readability) | 835 # containing directories get populated first and for readability) |
836 deps = self._ParseAllDeps(entries, entries_deps_content) | 836 deps = self._ParseAllDeps(entries, entries_deps_content) |
837 deps_to_process = deps.keys() | 837 deps_to_process = deps.keys() |
838 deps_to_process.sort() | 838 deps_to_process.sort() |
839 | 839 |
840 # First pass for direct dependencies. | 840 # First pass for direct dependencies. |
841 for d in deps_to_process: | 841 for d in deps_to_process: |
842 if type(deps[d]) == str: | 842 if type(deps[d]) == str: |
843 (url, rev) = GetURLAndRev(d, deps[d]) | 843 (url, rev) = GetURLAndRev(d, deps[d]) |
844 entries[d] = "%s@%d" % (url, rev) | 844 entries[d] = "%s@%d" % (url, rev) |
845 | 845 |
846 # Second pass for inherited deps (via the From keyword) | 846 # Second pass for inherited deps (via the From keyword) |
847 for d in deps_to_process: | 847 for d in deps_to_process: |
848 if type(deps[d]) != str: | 848 if type(deps[d]) != str: |
849 deps_parent_url = entries[deps[d].module_name] | 849 deps_parent_url = entries[deps[d].module_name] |
850 if deps_parent_url.find("@") < 0: | 850 if deps_parent_url.find("@") < 0: |
851 raise Error("From %s missing revisioned url" % deps[d].module_name) | 851 raise Error("From %s missing revisioned url" % deps[d].module_name) |
852 deps_parent_url_components = deps_parent_url.split("@") | 852 deps_parent_url_components = deps_parent_url.split("@") |
853 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) | 853 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) |
854 deps_parent_content = CaptureSVN( | 854 deps_parent_content = gclient_scm.CaptureSVN( |
855 ["cat", | 855 ["cat", |
856 "%s/%s@%s" % (deps_parent_url_components[0], | 856 "%s/%s@%s" % (deps_parent_url_components[0], |
857 self._options.deps_file, | 857 self._options.deps_file, |
858 deps_parent_url_components[1])], | 858 deps_parent_url_components[1])], |
859 os.getcwd()) | 859 os.getcwd()) |
860 sub_deps = self._ParseSolutionDeps( | 860 sub_deps = self._ParseSolutionDeps( |
861 deps[d].module_name, | 861 deps[d].module_name, |
862 FileRead(os.path.join(self._root_dir, | 862 FileRead(os.path.join(self._root_dir, |
863 deps[d].module_name, | 863 deps[d].module_name, |
864 self._options.deps_file)), | 864 self._options.deps_file)), |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 | 1179 |
1180 if "__main__" == __name__: | 1180 if "__main__" == __name__: |
1181 try: | 1181 try: |
1182 result = Main(sys.argv) | 1182 result = Main(sys.argv) |
1183 except Error, e: | 1183 except Error, e: |
1184 print >> sys.stderr, "Error: %s" % str(e) | 1184 print >> sys.stderr, "Error: %s" % str(e) |
1185 result = 1 | 1185 result = 1 |
1186 sys.exit(result) | 1186 sys.exit(result) |
1187 | 1187 |
1188 # vim: ts=2:sw=2:tw=80:et: | 1188 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |