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

Side by Side Diff: gclient.py

Issue 660299: Fix revinfo with git (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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 else: 766 else:
767 # Delete the entry 767 # Delete the entry
768 print("\n________ deleting \'%s\' " + 768 print("\n________ deleting \'%s\' " +
769 "in \'%s\'") % (entry_fixed, self._root_dir) 769 "in \'%s\'") % (entry_fixed, self._root_dir)
770 gclient_utils.RemoveDirectory(e_dir) 770 gclient_utils.RemoveDirectory(e_dir)
771 # record the current list of entries for next time 771 # record the current list of entries for next time
772 self._SaveEntries(entries) 772 self._SaveEntries(entries)
773 773
774 def PrintRevInfo(self): 774 def PrintRevInfo(self):
775 """Output revision info mapping for the client and its dependencies. This 775 """Output revision info mapping for the client and its dependencies. This
776 allows the capture of a overall "revision" for the source tree that can 776 allows the capture of an overall "revision" for the source tree that can
777 be used to reproduce the same tree in the future. The actual output 777 be used to reproduce the same tree in the future. The actual output
778 contains enough information (source paths, svn server urls and revisions) 778 contains enough information (source paths, svn server urls and revisions)
779 that it can be used either to generate external svn commands (without 779 that it can be used either to generate external svn commands (without
780 gclient) or as input to gclient's --rev option (with some massaging of 780 gclient) or as input to gclient's --rev option (with some massaging of
781 the data). 781 the data).
782 782
783 NOTE: Unlike RunOnDeps this does not require a local checkout and is run
784 on the Pulse master. It MUST NOT execute hooks.
785
786 Raises: 783 Raises:
787 Error: If the client has conflicting entries. 784 Error: If the client has conflicting entries.
788 """ 785 """
789 # Check for revision overrides. 786 # Check for revision overrides.
790 revision_overrides = {} 787 revision_overrides = {}
791 for revision in self._options.revisions: 788 for revision in self._options.revisions:
792 if revision.find("@") < 0: 789 if revision.find("@") < 0:
793 raise gclient_utils.Error( 790 raise gclient_utils.Error(
794 "Specify the full dependency when specifying a revision number.") 791 "Specify the full dependency when specifying a revision number.")
795 revision_elem = revision.split("@") 792 revision_elem = revision.split("@")
(...skipping 27 matching lines...) Expand all
823 else: 820 else:
824 return (url, revision) 821 return (url, revision)
825 822
826 # Run on the base solutions first. 823 # Run on the base solutions first.
827 for solution in solutions: 824 for solution in solutions:
828 name = solution["name"] 825 name = solution["name"]
829 if name in entries: 826 if name in entries:
830 raise gclient_utils.Error("solution %s specified more than once" % name) 827 raise gclient_utils.Error("solution %s specified more than once" % name)
831 (url, rev) = GetURLAndRev(name, solution["url"]) 828 (url, rev) = GetURLAndRev(name, solution["url"])
832 entries[name] = "%s@%s" % (url, rev) 829 entries[name] = "%s@%s" % (url, rev)
833 # TODO(aharper): SVN/SCMWrapper cleanup (non-local commandset) 830 deps_file = solution.get("deps_file", self._options.deps_file)
834 entries_deps_content[name] = gclient_scm.scm.SVN.Capture( 831 if '/' in deps_file or '\\' in deps_file:
835 ["cat", 832 raise gclient_utils.Error('deps_file name must not be a path, just a '
836 "%s/%s@%s" % (url, 833 'filename.')
837 self._options.deps_file, 834 try:
838 rev)], 835 deps_content = gclient_utils.FileRead(
839 os.getcwd()) 836 os.path.join(self._root_dir, name, deps_file))
837 except IOError, e:
838 if e.errno != errno.ENOENT:
839 raise
840 deps_content = ""
841 entries_deps_content[name] = deps_content
840 842
841 # Process the dependencies next (sort alphanumerically to ensure that 843 # Process the dependencies next (sort alphanumerically to ensure that
842 # containing directories get populated first and for readability) 844 # containing directories get populated first and for readability)
843 deps = self._ParseAllDeps(entries, entries_deps_content) 845 deps = self._ParseAllDeps(entries, entries_deps_content)
844 deps_to_process = deps.keys() 846 deps_to_process = deps.keys()
845 deps_to_process.sort() 847 deps_to_process.sort()
846 848
847 # First pass for direct dependencies. 849 # First pass for direct dependencies.
848 for d in deps_to_process: 850 for d in deps_to_process:
849 if type(deps[d]) == str: 851 if type(deps[d]) == str:
850 (url, rev) = GetURLAndRev(d, deps[d]) 852 (url, rev) = GetURLAndRev(d, deps[d])
851 entries[d] = "%s@%s" % (url, rev) 853 entries[d] = "%s@%s" % (url, rev)
852 854
853 # Second pass for inherited deps (via the From keyword) 855 # Second pass for inherited deps (via the From keyword)
854 for d in deps_to_process: 856 for d in deps_to_process:
855 if type(deps[d]) != str: 857 if type(deps[d]) != str:
856 deps_parent_url = entries[deps[d].module_name] 858 deps_parent_url = entries[deps[d].module_name]
857 if deps_parent_url.find("@") < 0: 859 if deps_parent_url.find("@") < 0:
858 raise gclient_utils.Error("From %s missing revisioned url" % 860 raise gclient_utils.Error("From %s missing revisioned url" %
859 deps[d].module_name) 861 deps[d].module_name)
860 content = gclient_utils.FileRead(os.path.join(self._root_dir, 862 content = gclient_utils.FileRead(os.path.join(self._root_dir,
861 deps[d].module_name, 863 deps[d].module_name,
862 self._options.deps_file)) 864 self._options.deps_file))
863 sub_deps = self._ParseSolutionDeps(deps[d].module_name, content, {}) 865 sub_deps = self._ParseSolutionDeps(deps[d].module_name, content, {})
864 (url, rev) = GetURLAndRev(d, sub_deps[d]) 866 (url, rev) = GetURLAndRev(d, sub_deps[d])
865 entries[d] = "%s@%s" % (url, rev) 867 entries[d] = "%s@%s" % (url, rev)
866 print(";\n\n".join(["%s: %s" % (x, entries[x]) 868 print(";\n".join(["%s: %s" % (x, entries[x])
867 for x in sorted(entries.keys())])) 869 for x in sorted(entries.keys())]))
868 870
869 871
870 ## gclient commands. 872 ## gclient commands.
871 873
872 874
873 def DoCleanup(options, args): 875 def DoCleanup(options, args):
874 """Handle the cleanup subcommand. 876 """Handle the cleanup subcommand.
875 877
876 Raises: 878 Raises:
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 1186
1185 if "__main__" == __name__: 1187 if "__main__" == __name__:
1186 try: 1188 try:
1187 result = Main(sys.argv) 1189 result = Main(sys.argv)
1188 except gclient_utils.Error, e: 1190 except gclient_utils.Error, e:
1189 print >> sys.stderr, "Error: %s" % str(e) 1191 print >> sys.stderr, "Error: %s" % str(e)
1190 result = 1 1192 result = 1
1191 sys.exit(result) 1193 sys.exit(result)
1192 1194
1193 # vim: ts=2:sw=2:tw=80:et: 1195 # 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