Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: gclient.py

Issue 208060: gclient: store revision as a string and not int (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 raise Error("No solution specified") 798 raise Error("No solution specified")
799 799
800 entries = {} 800 entries = {}
801 entries_deps_content = {} 801 entries_deps_content = {}
802 802
803 # Inner helper to generate base url and rev tuple (including honoring 803 # Inner helper to generate base url and rev tuple (including honoring
804 # |revision_overrides|) 804 # |revision_overrides|)
805 def GetURLAndRev(name, original_url): 805 def GetURLAndRev(name, original_url):
806 if original_url.find("@") < 0: 806 if original_url.find("@") < 0:
807 if revision_overrides.has_key(name): 807 if revision_overrides.has_key(name):
808 return (original_url, int(revision_overrides[name])) 808 return (original_url, revision_overrides[name])
809 else: 809 else:
810 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) 810 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset)
811 return (original_url, 811 return (original_url,
812 gclient_scm.CaptureSVNHeadRevision(original_url)) 812 gclient_scm.CaptureSVNHeadRevision(original_url))
813 else: 813 else:
814 url_components = original_url.split("@") 814 url_components = original_url.split("@")
815 if revision_overrides.has_key(name): 815 if revision_overrides.has_key(name):
816 return (url_components[0], int(revision_overrides[name])) 816 return (url_components[0], revision_overrides[name])
817 else: 817 else:
818 return (url_components[0], int(url_components[1])) 818 return (url_components[0], url_components[1])
819 819
820 # Run on the base solutions first. 820 # Run on the base solutions first.
821 for solution in solutions: 821 for solution in solutions:
822 name = solution["name"] 822 name = solution["name"]
823 if name in entries: 823 if name in entries:
824 raise Error("solution %s specified more than once" % name) 824 raise Error("solution %s specified more than once" % name)
825 (url, rev) = GetURLAndRev(name, solution["url"]) 825 (url, rev) = GetURLAndRev(name, solution["url"])
826 entries[name] = "%s@%d" % (url, rev) 826 entries[name] = "%s@%s" % (url, rev)
827 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) 827 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset)
828 entries_deps_content[name] = gclient_scm.CaptureSVN( 828 entries_deps_content[name] = gclient_scm.CaptureSVN(
829 ["cat", 829 ["cat",
830 "%s/%s@%d" % (url, 830 "%s/%s@%s" % (url,
831 self._options.deps_file, 831 self._options.deps_file,
832 rev)], 832 rev)],
833 os.getcwd()) 833 os.getcwd())
834 834
835 # Process the dependencies next (sort alphanumerically to ensure that 835 # Process the dependencies next (sort alphanumerically to ensure that
836 # containing directories get populated first and for readability) 836 # containing directories get populated first and for readability)
837 deps = self._ParseAllDeps(entries, entries_deps_content) 837 deps = self._ParseAllDeps(entries, entries_deps_content)
838 deps_to_process = deps.keys() 838 deps_to_process = deps.keys()
839 deps_to_process.sort() 839 deps_to_process.sort()
840 840
841 # First pass for direct dependencies. 841 # First pass for direct dependencies.
842 for d in deps_to_process: 842 for d in deps_to_process:
843 if type(deps[d]) == str: 843 if type(deps[d]) == str:
844 (url, rev) = GetURLAndRev(d, deps[d]) 844 (url, rev) = GetURLAndRev(d, deps[d])
845 entries[d] = "%s@%d" % (url, rev) 845 entries[d] = "%s@%s" % (url, rev)
846 846
847 # Second pass for inherited deps (via the From keyword) 847 # Second pass for inherited deps (via the From keyword)
848 for d in deps_to_process: 848 for d in deps_to_process:
849 if type(deps[d]) != str: 849 if type(deps[d]) != str:
850 deps_parent_url = entries[deps[d].module_name] 850 deps_parent_url = entries[deps[d].module_name]
851 if deps_parent_url.find("@") < 0: 851 if deps_parent_url.find("@") < 0:
852 raise Error("From %s missing revisioned url" % deps[d].module_name) 852 raise Error("From %s missing revisioned url" % deps[d].module_name)
853 deps_parent_url_components = deps_parent_url.split("@") 853 deps_parent_url_components = deps_parent_url.split("@")
854 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) 854 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset)
855 deps_parent_content = gclient_scm.CaptureSVN( 855 deps_parent_content = gclient_scm.CaptureSVN(
856 ["cat", 856 ["cat",
857 "%s/%s@%s" % (deps_parent_url_components[0], 857 "%s/%s@%s" % (deps_parent_url_components[0],
858 self._options.deps_file, 858 self._options.deps_file,
859 deps_parent_url_components[1])], 859 deps_parent_url_components[1])],
860 os.getcwd()) 860 os.getcwd())
861 sub_deps = self._ParseSolutionDeps( 861 sub_deps = self._ParseSolutionDeps(
862 deps[d].module_name, 862 deps[d].module_name,
863 FileRead(os.path.join(self._root_dir, 863 FileRead(os.path.join(self._root_dir,
864 deps[d].module_name, 864 deps[d].module_name,
865 self._options.deps_file)), 865 self._options.deps_file)),
866 {}) 866 {})
867 (url, rev) = GetURLAndRev(d, sub_deps[d]) 867 (url, rev) = GetURLAndRev(d, sub_deps[d])
868 entries[d] = "%s@%d" % (url, rev) 868 entries[d] = "%s@%s" % (url, rev)
869 print(";\n\n".join(["%s: %s" % (x, entries[x]) 869 print(";\n\n".join(["%s: %s" % (x, entries[x])
870 for x in sorted(entries.keys())])) 870 for x in sorted(entries.keys())]))
871 871
872 872
873 ## gclient commands. 873 ## gclient commands.
874 874
875 875
876 def DoCleanup(options, args): 876 def DoCleanup(options, args):
877 """Handle the cleanup subcommand. 877 """Handle the cleanup subcommand.
878 878
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1183 1183
1184 if "__main__" == __name__: 1184 if "__main__" == __name__:
1185 try: 1185 try:
1186 result = Main(sys.argv) 1186 result = Main(sys.argv)
1187 except Error, e: 1187 except Error, e:
1188 print >> sys.stderr, "Error: %s" % str(e) 1188 print >> sys.stderr, "Error: %s" % str(e)
1189 result = 1 1189 result = 1
1190 sys.exit(result) 1190 sys.exit(result)
1191 1191
1192 # vim: ts=2:sw=2:tw=80:et: 1192 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698