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

Side by Side Diff: gclient.py

Issue 216014: gclient_scm: add test for unsupported scm (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') | gclient_scm.py » ('J')
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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 else: 547 else:
548 parsed_url = urlparse.urlparse(url) 548 parsed_url = urlparse.urlparse(url)
549 scheme = parsed_url[0] 549 scheme = parsed_url[0]
550 if not scheme: 550 if not scheme:
551 # A relative url. Fetch the real base. 551 # A relative url. Fetch the real base.
552 path = parsed_url[2] 552 path = parsed_url[2]
553 if path[0] != "/": 553 if path[0] != "/":
554 raise Error( 554 raise Error(
555 "relative DEPS entry \"%s\" must begin with a slash" % d) 555 "relative DEPS entry \"%s\" must begin with a slash" % d)
556 # Create a scm just to query the full url. 556 # Create a scm just to query the full url.
557 scm = gclient_scm.SCMWrapper(solution["url"], self._root_dir, 557 scm = gclient_scm.create_scm(solution["url"], self._root_dir,
558 None) 558 None)
559 url = scm.FullUrlForRelativeUrl(url) 559 url = scm.FullUrlForRelativeUrl(url)
560 if d in deps and deps[d] != url: 560 if d in deps and deps[d] != url:
561 raise Error( 561 raise Error(
562 "Solutions have conflicting versions of dependency \"%s\"" % d) 562 "Solutions have conflicting versions of dependency \"%s\"" % d)
563 if d in solution_urls and solution_urls[d] != url: 563 if d in solution_urls and solution_urls[d] != url:
564 raise Error( 564 raise Error(
565 "Dependency \"%s\" conflicts with specified solution" % d) 565 "Dependency \"%s\" conflicts with specified solution" % d)
566 # Grab the dependency. 566 # Grab the dependency.
567 deps[d] = url 567 deps[d] = url
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 name = solution["name"] 664 name = solution["name"]
665 deps_file = solution.get("deps_file", self._options.deps_file) 665 deps_file = solution.get("deps_file", self._options.deps_file)
666 if '/' in deps_file or '\\' in deps_file: 666 if '/' in deps_file or '\\' in deps_file:
667 raise Error("deps_file name must not be a path, just a filename.") 667 raise Error("deps_file name must not be a path, just a filename.")
668 if name in entries: 668 if name in entries:
669 raise Error("solution %s specified more than once" % name) 669 raise Error("solution %s specified more than once" % name)
670 url = solution["url"] 670 url = solution["url"]
671 entries[name] = url 671 entries[name] = url
672 if run_scm: 672 if run_scm:
673 self._options.revision = revision_overrides.get(name) 673 self._options.revision = revision_overrides.get(name)
674 scm = gclient_scm.SCMWrapper(url, self._root_dir, name) 674 scm = gclient_scm.create_scm(url, self._root_dir, name)
675 scm.RunCommand(command, self._options, args, file_list) 675 scm.RunCommand(command, self._options, args, file_list)
676 file_list = [os.path.join(name, file.strip()) for file in file_list] 676 file_list = [os.path.join(name, file.strip()) for file in file_list]
677 self._options.revision = None 677 self._options.revision = None
678 try: 678 try:
679 deps_content = FileRead(os.path.join(self._root_dir, name, 679 deps_content = FileRead(os.path.join(self._root_dir, name,
680 deps_file)) 680 deps_file))
681 except IOError, e: 681 except IOError, e:
682 if e.errno != errno.ENOENT: 682 if e.errno != errno.ENOENT:
683 raise 683 raise
684 deps_content = "" 684 deps_content = ""
685 entries_deps_content[name] = deps_content 685 entries_deps_content[name] = deps_content
686 686
687 # Process the dependencies next (sort alphanumerically to ensure that 687 # Process the dependencies next (sort alphanumerically to ensure that
688 # containing directories get populated first and for readability) 688 # containing directories get populated first and for readability)
689 deps = self._ParseAllDeps(entries, entries_deps_content) 689 deps = self._ParseAllDeps(entries, entries_deps_content)
690 deps_to_process = deps.keys() 690 deps_to_process = deps.keys()
691 deps_to_process.sort() 691 deps_to_process.sort()
692 692
693 # First pass for direct dependencies. 693 # First pass for direct dependencies.
694 for d in deps_to_process: 694 for d in deps_to_process:
695 if type(deps[d]) == str: 695 if type(deps[d]) == str:
696 url = deps[d] 696 url = deps[d]
697 entries[d] = url 697 entries[d] = url
698 if run_scm: 698 if run_scm:
699 self._options.revision = revision_overrides.get(d) 699 self._options.revision = revision_overrides.get(d)
700 scm = gclient_scm.SCMWrapper(url, self._root_dir, d) 700 scm = gclient_scm.create_scm(url, self._root_dir, d)
701 scm.RunCommand(command, self._options, args, file_list) 701 scm.RunCommand(command, self._options, args, file_list)
702 self._options.revision = None 702 self._options.revision = None
703 703
704 # Second pass for inherited deps (via the From keyword) 704 # Second pass for inherited deps (via the From keyword)
705 for d in deps_to_process: 705 for d in deps_to_process:
706 if type(deps[d]) != str: 706 if type(deps[d]) != str:
707 sub_deps = self._ParseSolutionDeps( 707 sub_deps = self._ParseSolutionDeps(
708 deps[d].module_name, 708 deps[d].module_name,
709 FileRead(os.path.join(self._root_dir, 709 FileRead(os.path.join(self._root_dir,
710 deps[d].module_name, 710 deps[d].module_name,
711 self._options.deps_file)), 711 self._options.deps_file)),
712 {}) 712 {})
713 url = sub_deps[d] 713 url = sub_deps[d]
714 entries[d] = url 714 entries[d] = url
715 if run_scm: 715 if run_scm:
716 self._options.revision = revision_overrides.get(d) 716 self._options.revision = revision_overrides.get(d)
717 scm = gclient_scm.SCMWrapper(url, self._root_dir, d) 717 scm = gclient_scm.create_scm(url, self._root_dir, d)
718 scm.RunCommand(command, self._options, args, file_list) 718 scm.RunCommand(command, self._options, args, file_list)
719 self._options.revision = None 719 self._options.revision = None
720 720
721 # Convert all absolute paths to relative. 721 # Convert all absolute paths to relative.
722 for i in range(len(file_list)): 722 for i in range(len(file_list)):
723 # TODO(phajdan.jr): We should know exactly when the paths are absolute. 723 # TODO(phajdan.jr): We should know exactly when the paths are absolute.
724 # It depends on the command being executed (like runhooks vs sync). 724 # It depends on the command being executed (like runhooks vs sync).
725 if not os.path.isabs(file_list[i]): 725 if not os.path.isabs(file_list[i]):
726 continue 726 continue
727 727
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:
OLDNEW
« no previous file with comments | « no previous file | gclient_scm.py » ('j') | gclient_scm.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698