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

Side by Side Diff: gclient.py

Issue 900001: r41078 broke revinfo for .gclient files with multiple solutions (Closed)
Patch Set: Created 10 years, 9 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 | no next file » | 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 # 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 """A wrapper script to manage a set of client modules in different SCM. 6 """A wrapper script to manage a set of client modules in different SCM.
7 7
8 This script is intended to be used to help basic management of client 8 This script is intended to be used to help basic management of client
9 program sources residing in one or more Subversion modules and Git 9 program sources residing in one or more Subversion modules and Git
10 repositories, along with other modules it depends on, also in Subversion or Git, 10 repositories, along with other modules it depends on, also in Subversion or Git,
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 else: 840 else:
841 if revision_overrides.has_key(name): 841 if revision_overrides.has_key(name):
842 return (url, revision_overrides[name]) 842 return (url, revision_overrides[name])
843 else: 843 else:
844 return (url, revision) 844 return (url, revision)
845 845
846 # text of the snapshot gclient file 846 # text of the snapshot gclient file
847 new_gclient = "" 847 new_gclient = ""
848 # Dictionary of { path : SCM url } to ensure no duplicate solutions 848 # Dictionary of { path : SCM url } to ensure no duplicate solutions
849 solution_names = {} 849 solution_names = {}
850 entries = {}
851 entries_deps_content = {}
850 # Run on the base solutions first. 852 # Run on the base solutions first.
851 for solution in solutions: 853 for solution in solutions:
852 # Dictionary of { path : SCM url } to describe the gclient checkout 854 # Dictionary of { path : SCM url } to describe the gclient checkout
853 entries = {}
854 entries_deps_content = {}
855 name = solution["name"] 855 name = solution["name"]
856 if name in solution_names: 856 if name in solution_names:
857 raise gclient_utils.Error("solution %s specified more than once" % name) 857 raise gclient_utils.Error("solution %s specified more than once" % name)
858 (url, rev) = GetURLAndRev(name, solution["url"]) 858 (url, rev) = GetURLAndRev(name, solution["url"])
859 entries[name] = "%s@%s" % (url, rev) 859 entries[name] = "%s@%s" % (url, rev)
860 solution_names[name] = "%s@%s" % (url, rev) 860 solution_names[name] = "%s@%s" % (url, rev)
861 deps_file = solution.get("deps_file", self._options.deps_file) 861 deps_file = solution.get("deps_file", self._options.deps_file)
862 if '/' in deps_file or '\\' in deps_file: 862 if '/' in deps_file or '\\' in deps_file:
863 raise gclient_utils.Error('deps_file name must not be a path, just a ' 863 raise gclient_utils.Error('deps_file name must not be a path, just a '
864 'filename.') 864 'filename.')
865 try: 865 try:
866 deps_content = gclient_utils.FileRead( 866 deps_content = gclient_utils.FileRead(
867 os.path.join(self._root_dir, name, deps_file)) 867 os.path.join(self._root_dir, name, deps_file))
868 except IOError, e: 868 except IOError, e:
869 if e.errno != errno.ENOENT: 869 if e.errno != errno.ENOENT:
870 raise 870 raise
871 deps_content = "" 871 deps_content = ""
872 entries_deps_content[name] = deps_content 872 entries_deps_content[name] = deps_content
873 873
874 # Process the dependencies next (sort alphanumerically to ensure that 874 # Process the dependencies next (sort alphanumerically to ensure that
875 # containing directories get populated first and for readability) 875 # containing directories get populated first and for readability)
876 deps = self._ParseAllDeps(entries, entries_deps_content) 876 # DEBUG
M-A Ruel 2010/03/11 23:46:07 Remove this please.
877 deps_to_process = deps.keys() 877 #print "entries\n%s\nentries_deps_content\n%s" % (entries, entries_deps_cont ent)
878 deps_to_process.sort() 878 # END DEBUG
879 deps = self._ParseAllDeps(entries, entries_deps_content)
880 deps_to_process = deps.keys()
881 deps_to_process.sort()
879 882
880 # First pass for direct dependencies. 883 # First pass for direct dependencies.
881 for d in deps_to_process: 884 for d in deps_to_process:
882 if type(deps[d]) == str: 885 if type(deps[d]) == str:
883 (url, rev) = GetURLAndRev(d, deps[d]) 886 (url, rev) = GetURLAndRev(d, deps[d])
884 entries[d] = "%s@%s" % (url, rev) 887 entries[d] = "%s@%s" % (url, rev)
885 888
886 # Second pass for inherited deps (via the From keyword) 889 # Second pass for inherited deps (via the From keyword)
887 for d in deps_to_process: 890 for d in deps_to_process:
888 if type(deps[d]) != str: 891 if type(deps[d]) != str:
889 deps_parent_url = entries[deps[d].module_name] 892 deps_parent_url = entries[deps[d].module_name]
890 if deps_parent_url.find("@") < 0: 893 if deps_parent_url.find("@") < 0:
891 raise gclient_utils.Error("From %s missing revisioned url" % 894 raise gclient_utils.Error("From %s missing revisioned url" %
892 deps[d].module_name) 895 deps[d].module_name)
893 content = gclient_utils.FileRead(os.path.join( 896 content = gclient_utils.FileRead(os.path.join(
894 self._root_dir, 897 self._root_dir,
895 deps[d].module_name, 898 deps[d].module_name,
896 self._options.deps_file)) 899 self._options.deps_file))
897 sub_deps = self._ParseSolutionDeps(deps[d].module_name, content, {}) 900 sub_deps = self._ParseSolutionDeps(deps[d].module_name, content, {})
898 (url, rev) = GetURLAndRev(d, sub_deps[d]) 901 (url, rev) = GetURLAndRev(d, sub_deps[d])
899 entries[d] = "%s@%s" % (url, rev) 902 entries[d] = "%s@%s" % (url, rev)
900 903
901 # Build the snapshot configuration string 904 # Build the snapshot configuration string
902 if self._options.snapshot: 905 if self._options.snapshot:
903 url = entries.pop(name) 906 url = entries.pop(name)
904 custom_deps = ",\n ".join(["\"%s\": \"%s\"" % (x, entries[x]) 907 custom_deps = ",\n ".join(["\"%s\": \"%s\"" % (x, entries[x])
905 for x in sorted(entries.keys())]) 908 for x in sorted(entries.keys())])
906 909
907 new_gclient += DEFAULT_SNAPSHOT_SOLUTION_TEXT % { 910 new_gclient += DEFAULT_SNAPSHOT_SOLUTION_TEXT % {
908 'solution_name': name, 911 'solution_name': name,
909 'solution_url': url, 912 'solution_url': url,
910 'safesync_url' : "", 913 'safesync_url' : "",
911 'solution_deps': custom_deps, 914 'solution_deps': custom_deps,
912 } 915 }
913 else: 916 else:
914 print(";\n".join(["%s: %s" % (x, entries[x]) 917 print(";\n".join(["%s: %s" % (x, entries[x])
915 for x in sorted(entries.keys())])) 918 for x in sorted(entries.keys())]))
916 919
917 # Print the snapshot configuration file 920 # Print the snapshot configuration file
918 if self._options.snapshot: 921 if self._options.snapshot:
919 config = DEFAULT_SNAPSHOT_FILE_TEXT % {'solution_list': new_gclient} 922 config = DEFAULT_SNAPSHOT_FILE_TEXT % {'solution_list': new_gclient}
920 snapclient = GClient(self._root_dir, self._options) 923 snapclient = GClient(self._root_dir, self._options)
921 snapclient.SetConfig(config) 924 snapclient.SetConfig(config)
922 print(snapclient._config_content) 925 print(snapclient._config_content)
923 926
924 927
925 ## gclient commands. 928 ## gclient commands.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 1250
1248 if "__main__" == __name__: 1251 if "__main__" == __name__:
1249 try: 1252 try:
1250 result = Main(sys.argv) 1253 result = Main(sys.argv)
1251 except gclient_utils.Error, e: 1254 except gclient_utils.Error, e:
1252 print >> sys.stderr, "Error: %s" % str(e) 1255 print >> sys.stderr, "Error: %s" % str(e)
1253 result = 1 1256 result = 1
1254 sys.exit(result) 1257 sys.exit(result)
1255 1258
1256 # vim: ts=2:sw=2:tw=80:et: 1259 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698