| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Meta checkout manager supporting both Subversion and GIT.""" | 6 """Meta checkout manager supporting both Subversion and GIT.""" |
| 7 # Files | 7 # Files |
| 8 # .gclient : Current client configuration, written by 'config' command. | 8 # .gclient : Current client configuration, written by 'config' command. |
| 9 # Format is a Python script defining 'solutions', a list whose | 9 # Format is a Python script defining 'solutions', a list whose |
| 10 # entries each are maps binding the strings "name" and "url" | 10 # entries each are maps binding the strings "name" and "url" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 # Example: | 69 # Example: |
| 70 # target_os = [ "android" ] | 70 # target_os = [ "android" ] |
| 71 # | 71 # |
| 72 # If the "target_os_only" key is also present and true, then *only* the | 72 # If the "target_os_only" key is also present and true, then *only* the |
| 73 # operating systems listed in "target_os" will be used. | 73 # operating systems listed in "target_os" will be used. |
| 74 # | 74 # |
| 75 # Example: | 75 # Example: |
| 76 # target_os = [ "ios" ] | 76 # target_os = [ "ios" ] |
| 77 # target_os_only = True | 77 # target_os_only = True |
| 78 | 78 |
| 79 from __future__ import print_function |
| 80 |
| 79 __version__ = '0.7' | 81 __version__ = '0.7' |
| 80 | 82 |
| 81 import ast | 83 import ast |
| 82 import copy | 84 import copy |
| 83 import json | 85 import json |
| 84 import logging | 86 import logging |
| 85 import optparse | 87 import optparse |
| 86 import os | 88 import os |
| 87 import platform | 89 import platform |
| 88 import posixpath | 90 import posixpath |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 # These are only set in .gclient and not in DEPS files. | 239 # These are only set in .gclient and not in DEPS files. |
| 238 self._custom_vars = custom_vars or {} | 240 self._custom_vars = custom_vars or {} |
| 239 self._custom_deps = custom_deps or {} | 241 self._custom_deps = custom_deps or {} |
| 240 self._custom_hooks = custom_hooks or [] | 242 self._custom_hooks = custom_hooks or [] |
| 241 | 243 |
| 242 # TODO(iannucci): Remove this when all masters are correctly substituting | 244 # TODO(iannucci): Remove this when all masters are correctly substituting |
| 243 # the new blink url. | 245 # the new blink url. |
| 244 if (self._custom_vars.get('webkit_trunk', '') == | 246 if (self._custom_vars.get('webkit_trunk', '') == |
| 245 'svn://svn-mirror.golo.chromium.org/webkit-readonly/trunk'): | 247 'svn://svn-mirror.golo.chromium.org/webkit-readonly/trunk'): |
| 246 new_url = 'svn://svn-mirror.golo.chromium.org/blink/trunk' | 248 new_url = 'svn://svn-mirror.golo.chromium.org/blink/trunk' |
| 247 print 'Overwriting Var("webkit_trunk") with %s' % new_url | 249 print('Overwriting Var("webkit_trunk") with %s' % new_url) |
| 248 self._custom_vars['webkit_trunk'] = new_url | 250 self._custom_vars['webkit_trunk'] = new_url |
| 249 | 251 |
| 250 # Post process the url to remove trailing slashes. | 252 # Post process the url to remove trailing slashes. |
| 251 if isinstance(self._url, basestring): | 253 if isinstance(self._url, basestring): |
| 252 # urls are sometime incorrectly written as proto://host/path/@rev. Replace | 254 # urls are sometime incorrectly written as proto://host/path/@rev. Replace |
| 253 # it to proto://host/path@rev. | 255 # it to proto://host/path@rev. |
| 254 self._url = self._url.replace('/@', '@') | 256 self._url = self._url.replace('/@', '@') |
| 255 elif not isinstance(self._url, | 257 elif not isinstance(self._url, |
| 256 (self.FromImpl, self.FileImpl, None.__class__)): | 258 (self.FromImpl, self.FileImpl, None.__class__)): |
| 257 raise gclient_utils.Error( | 259 raise gclient_utils.Error( |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 """Git-specific path marshaling. It is optimized for git-grep.""" | 879 """Git-specific path marshaling. It is optimized for git-grep.""" |
| 878 | 880 |
| 879 def mod_path(git_pathspec): | 881 def mod_path(git_pathspec): |
| 880 match = re.match('^(\\S+?:)?([^\0]+)$', git_pathspec) | 882 match = re.match('^(\\S+?:)?([^\0]+)$', git_pathspec) |
| 881 modified_path = os.path.join(self.name, match.group(2)) | 883 modified_path = os.path.join(self.name, match.group(2)) |
| 882 branch = match.group(1) or '' | 884 branch = match.group(1) or '' |
| 883 return '%s%s' % (branch, modified_path) | 885 return '%s%s' % (branch, modified_path) |
| 884 | 886 |
| 885 match = re.match('^Binary file ([^\0]+) matches$', line) | 887 match = re.match('^Binary file ([^\0]+) matches$', line) |
| 886 if match: | 888 if match: |
| 887 print 'Binary file %s matches\n' % mod_path(match.group(1)) | 889 print('Binary file %s matches\n' % mod_path(match.group(1))) |
| 888 return | 890 return |
| 889 | 891 |
| 890 items = line.split('\0') | 892 items = line.split('\0') |
| 891 if len(items) == 2 and items[1]: | 893 if len(items) == 2 and items[1]: |
| 892 print '%s : %s' % (mod_path(items[0]), items[1]) | 894 print('%s : %s' % (mod_path(items[0]), items[1])) |
| 893 elif len(items) >= 2: | 895 elif len(items) >= 2: |
| 894 # Multiple null bytes or a single trailing null byte indicate | 896 # Multiple null bytes or a single trailing null byte indicate |
| 895 # git is likely displaying filenames only (such as with -l) | 897 # git is likely displaying filenames only (such as with -l) |
| 896 print '\n'.join(mod_path(path) for path in items if path) | 898 print('\n'.join(mod_path(path) for path in items if path)) |
| 897 else: | 899 else: |
| 898 print line | 900 print(line) |
| 899 else: | 901 else: |
| 900 print_stdout = True | 902 print_stdout = True |
| 901 filter_fn = None | 903 filter_fn = None |
| 902 | 904 |
| 903 if parsed_url is None: | 905 if parsed_url is None: |
| 904 print >> sys.stderr, 'Skipped omitted dependency %s' % cwd | 906 print('Skipped omitted dependency %s' % cwd, file=sys.stderr) |
| 905 elif os.path.isdir(cwd): | 907 elif os.path.isdir(cwd): |
| 906 try: | 908 try: |
| 907 gclient_utils.CheckCallAndFilter( | 909 gclient_utils.CheckCallAndFilter( |
| 908 args, cwd=cwd, env=env, print_stdout=print_stdout, | 910 args, cwd=cwd, env=env, print_stdout=print_stdout, |
| 909 filter_fn=filter_fn, | 911 filter_fn=filter_fn, |
| 910 ) | 912 ) |
| 911 except subprocess2.CalledProcessError: | 913 except subprocess2.CalledProcessError: |
| 912 if not options.ignore: | 914 if not options.ignore: |
| 913 raise | 915 raise |
| 914 else: | 916 else: |
| 915 print >> sys.stderr, 'Skipped missing %s' % cwd | 917 print('Skipped missing %s' % cwd, file=sys.stderr) |
| 916 | 918 |
| 917 | 919 |
| 918 @gclient_utils.lockedmethod | 920 @gclient_utils.lockedmethod |
| 919 def _run_is_done(self, file_list, parsed_url): | 921 def _run_is_done(self, file_list, parsed_url): |
| 920 # Both these are kept for hooks that are run as a separate tree traversal. | 922 # Both these are kept for hooks that are run as a separate tree traversal. |
| 921 self._file_list = file_list | 923 self._file_list = file_list |
| 922 self._parsed_url = parsed_url | 924 self._parsed_url = parsed_url |
| 923 self._processed = True | 925 self._processed = True |
| 924 | 926 |
| 925 @staticmethod | 927 @staticmethod |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 self._hooks_ran = True | 980 self._hooks_ran = True |
| 979 for hook in self.GetHooks(options): | 981 for hook in self.GetHooks(options): |
| 980 try: | 982 try: |
| 981 start_time = time.time() | 983 start_time = time.time() |
| 982 gclient_utils.CheckCallAndFilterAndHeader( | 984 gclient_utils.CheckCallAndFilterAndHeader( |
| 983 hook, cwd=self.root.root_dir, always=True) | 985 hook, cwd=self.root.root_dir, always=True) |
| 984 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 986 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 985 # Use a discrete exit status code of 2 to indicate that a hook action | 987 # Use a discrete exit status code of 2 to indicate that a hook action |
| 986 # failed. Users of this script may wish to treat hook action failures | 988 # failed. Users of this script may wish to treat hook action failures |
| 987 # differently from VC failures. | 989 # differently from VC failures. |
| 988 print >> sys.stderr, 'Error: %s' % str(e) | 990 print('Error: %s' % str(e), file=sys.stderr) |
| 989 sys.exit(2) | 991 sys.exit(2) |
| 990 finally: | 992 finally: |
| 991 elapsed_time = time.time() - start_time | 993 elapsed_time = time.time() - start_time |
| 992 if elapsed_time > 10: | 994 if elapsed_time > 10: |
| 993 print "Hook '%s' took %.2f secs" % ( | 995 print("Hook '%s' took %.2f secs" % ( |
| 994 gclient_utils.CommandToStr(hook), elapsed_time) | 996 gclient_utils.CommandToStr(hook), elapsed_time)) |
| 995 | 997 |
| 996 def RunPreDepsHooks(self): | 998 def RunPreDepsHooks(self): |
| 997 assert self.processed | 999 assert self.processed |
| 998 assert self.deps_parsed | 1000 assert self.deps_parsed |
| 999 assert not self.pre_deps_hooks_ran | 1001 assert not self.pre_deps_hooks_ran |
| 1000 assert not self.hooks_ran | 1002 assert not self.hooks_ran |
| 1001 for s in self.dependencies: | 1003 for s in self.dependencies: |
| 1002 assert not s.processed | 1004 assert not s.processed |
| 1003 self._pre_deps_hooks_ran = True | 1005 self._pre_deps_hooks_ran = True |
| 1004 for hook in self.pre_deps_hooks: | 1006 for hook in self.pre_deps_hooks: |
| 1005 try: | 1007 try: |
| 1006 start_time = time.time() | 1008 start_time = time.time() |
| 1007 gclient_utils.CheckCallAndFilterAndHeader( | 1009 gclient_utils.CheckCallAndFilterAndHeader( |
| 1008 hook, cwd=self.root.root_dir, always=True) | 1010 hook, cwd=self.root.root_dir, always=True) |
| 1009 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1011 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1010 # Use a discrete exit status code of 2 to indicate that a hook action | 1012 # Use a discrete exit status code of 2 to indicate that a hook action |
| 1011 # failed. Users of this script may wish to treat hook action failures | 1013 # failed. Users of this script may wish to treat hook action failures |
| 1012 # differently from VC failures. | 1014 # differently from VC failures. |
| 1013 print >> sys.stderr, 'Error: %s' % str(e) | 1015 print('Error: %s' % str(e), file=sys.stderr) |
| 1014 sys.exit(2) | 1016 sys.exit(2) |
| 1015 finally: | 1017 finally: |
| 1016 elapsed_time = time.time() - start_time | 1018 elapsed_time = time.time() - start_time |
| 1017 if elapsed_time > 10: | 1019 if elapsed_time > 10: |
| 1018 print "Hook '%s' took %.2f secs" % ( | 1020 print("Hook '%s' took %.2f secs" % ( |
| 1019 gclient_utils.CommandToStr(hook), elapsed_time) | 1021 gclient_utils.CommandToStr(hook), elapsed_time)) |
| 1020 | 1022 |
| 1021 | 1023 |
| 1022 def subtree(self, include_all): | 1024 def subtree(self, include_all): |
| 1023 """Breadth first recursion excluding root node.""" | 1025 """Breadth first recursion excluding root node.""" |
| 1024 dependencies = self.dependencies | 1026 dependencies = self.dependencies |
| 1025 for d in dependencies: | 1027 for d in dependencies: |
| 1026 if d.should_process or include_all: | 1028 if d.should_process or include_all: |
| 1027 yield d | 1029 yield d |
| 1028 for d in dependencies: | 1030 for d in dependencies: |
| 1029 for i in d.subtree(include_all): | 1031 for i in d.subtree(include_all): |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 if not path: | 1384 if not path: |
| 1383 return None | 1385 return None |
| 1384 client = GClient(path, options) | 1386 client = GClient(path, options) |
| 1385 client.SetConfig(gclient_utils.FileRead( | 1387 client.SetConfig(gclient_utils.FileRead( |
| 1386 os.path.join(path, options.config_filename))) | 1388 os.path.join(path, options.config_filename))) |
| 1387 client = client.MigrateConfigToGit(path, options) | 1389 client = client.MigrateConfigToGit(path, options) |
| 1388 | 1390 |
| 1389 if (options.revisions and | 1391 if (options.revisions and |
| 1390 len(client.dependencies) > 1 and | 1392 len(client.dependencies) > 1 and |
| 1391 any('@' not in r for r in options.revisions)): | 1393 any('@' not in r for r in options.revisions)): |
| 1392 print >> sys.stderr, ( | 1394 print( |
| 1393 'You must specify the full solution name like --revision %s@%s\n' | 1395 ('You must specify the full solution name like --revision %s@%s\n' |
| 1394 'when you have multiple solutions setup in your .gclient file.\n' | 1396 'when you have multiple solutions setup in your .gclient file.\n' |
| 1395 'Other solutions present are: %s.') % ( | 1397 'Other solutions present are: %s.') % ( |
| 1396 client.dependencies[0].name, | 1398 client.dependencies[0].name, |
| 1397 options.revisions[0], | 1399 options.revisions[0], |
| 1398 ', '.join(s.name for s in client.dependencies[1:])) | 1400 ', '.join(s.name for s in client.dependencies[1:])), |
| 1401 file=sys.stderr) |
| 1399 return client | 1402 return client |
| 1400 | 1403 |
| 1401 def SetDefaultConfig(self, solution_name, deps_file, solution_url, | 1404 def SetDefaultConfig(self, solution_name, deps_file, solution_url, |
| 1402 safesync_url, managed=True, cache_dir=None): | 1405 safesync_url, managed=True, cache_dir=None): |
| 1403 self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % { | 1406 self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % { |
| 1404 'solution_name': solution_name, | 1407 'solution_name': solution_name, |
| 1405 'solution_url': solution_url, | 1408 'solution_url': solution_url, |
| 1406 'deps_file': deps_file, | 1409 'deps_file': deps_file, |
| 1407 'safesync_url' : safesync_url, | 1410 'safesync_url' : safesync_url, |
| 1408 'managed': managed, | 1411 'managed': managed, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 pm = Progress('Syncing projects', 1) | 1515 pm = Progress('Syncing projects', 1) |
| 1513 elif command == 'recurse': | 1516 elif command == 'recurse': |
| 1514 pm = Progress(' '.join(args), 1) | 1517 pm = Progress(' '.join(args), 1) |
| 1515 work_queue = gclient_utils.ExecutionQueue( | 1518 work_queue = gclient_utils.ExecutionQueue( |
| 1516 self._options.jobs, pm, ignore_requirements=ignore_requirements, | 1519 self._options.jobs, pm, ignore_requirements=ignore_requirements, |
| 1517 verbose=self._options.verbose) | 1520 verbose=self._options.verbose) |
| 1518 for s in self.dependencies: | 1521 for s in self.dependencies: |
| 1519 work_queue.enqueue(s) | 1522 work_queue.enqueue(s) |
| 1520 work_queue.flush(revision_overrides, command, args, options=self._options) | 1523 work_queue.flush(revision_overrides, command, args, options=self._options) |
| 1521 if revision_overrides: | 1524 if revision_overrides: |
| 1522 print >> sys.stderr, ('Please fix your script, having invalid ' | 1525 print('Please fix your script, having invalid --revision flags will soon ' |
| 1523 '--revision flags will soon considered an error.') | 1526 'considered an error.', file=sys.stderr) |
| 1524 | 1527 |
| 1525 # Once all the dependencies have been processed, it's now safe to run the | 1528 # Once all the dependencies have been processed, it's now safe to run the |
| 1526 # hooks. | 1529 # hooks. |
| 1527 if not self._options.nohooks: | 1530 if not self._options.nohooks: |
| 1528 self.RunHooksRecursively(self._options) | 1531 self.RunHooksRecursively(self._options) |
| 1529 | 1532 |
| 1530 if command == 'update': | 1533 if command == 'update': |
| 1531 # Notify the user if there is an orphaned entry in their working copy. | 1534 # Notify the user if there is an orphaned entry in their working copy. |
| 1532 # Only delete the directory if there are no changes in it, and | 1535 # Only delete the directory if there are no changes in it, and |
| 1533 # delete_unversioned_trees is set to true. | 1536 # delete_unversioned_trees is set to true. |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 parser.add_option('-s', '--scm', action='append', default=[], | 1759 parser.add_option('-s', '--scm', action='append', default=[], |
| 1757 help='Choose scm types to operate upon.') | 1760 help='Choose scm types to operate upon.') |
| 1758 parser.add_option('-i', '--ignore', action='store_true', | 1761 parser.add_option('-i', '--ignore', action='store_true', |
| 1759 help='Ignore non-zero return codes from subcommands.') | 1762 help='Ignore non-zero return codes from subcommands.') |
| 1760 parser.add_option('--prepend-dir', action='store_true', | 1763 parser.add_option('--prepend-dir', action='store_true', |
| 1761 help='Prepend relative dir for use with git <cmd> --null.') | 1764 help='Prepend relative dir for use with git <cmd> --null.') |
| 1762 parser.add_option('--no-progress', action='store_true', | 1765 parser.add_option('--no-progress', action='store_true', |
| 1763 help='Disable progress bar that shows sub-command updates') | 1766 help='Disable progress bar that shows sub-command updates') |
| 1764 options, args = parser.parse_args(args) | 1767 options, args = parser.parse_args(args) |
| 1765 if not args: | 1768 if not args: |
| 1766 print >> sys.stderr, 'Need to supply a command!' | 1769 print('Need to supply a command!', file=sys.stderr) |
| 1767 return 1 | 1770 return 1 |
| 1768 root_and_entries = gclient_utils.GetGClientRootAndEntries() | 1771 root_and_entries = gclient_utils.GetGClientRootAndEntries() |
| 1769 if not root_and_entries: | 1772 if not root_and_entries: |
| 1770 print >> sys.stderr, ( | 1773 print( |
| 1771 'You need to run gclient sync at least once to use \'recurse\'.\n' | 1774 'You need to run gclient sync at least once to use \'recurse\'.\n' |
| 1772 'This is because .gclient_entries needs to exist and be up to date.') | 1775 'This is because .gclient_entries needs to exist and be up to date.', |
| 1776 file=sys.stderr) |
| 1773 return 1 | 1777 return 1 |
| 1774 | 1778 |
| 1775 # Normalize options.scm to a set() | 1779 # Normalize options.scm to a set() |
| 1776 scm_set = set() | 1780 scm_set = set() |
| 1777 for scm in options.scm: | 1781 for scm in options.scm: |
| 1778 scm_set.update(scm.split(',')) | 1782 scm_set.update(scm.split(',')) |
| 1779 options.scm = scm_set | 1783 options.scm = scm_set |
| 1780 | 1784 |
| 1781 options.nohooks = True | 1785 options.nohooks = True |
| 1782 client = GClient.LoadCurrentConfig(options) | 1786 client = GClient.LoadCurrentConfig(options) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1796 | 1800 |
| 1797 | 1801 |
| 1798 def CMDgrep(parser, args): | 1802 def CMDgrep(parser, args): |
| 1799 """Greps through git repos managed by gclient. | 1803 """Greps through git repos managed by gclient. |
| 1800 | 1804 |
| 1801 Runs 'git grep [args...]' for each module. | 1805 Runs 'git grep [args...]' for each module. |
| 1802 """ | 1806 """ |
| 1803 # We can't use optparse because it will try to parse arguments sent | 1807 # We can't use optparse because it will try to parse arguments sent |
| 1804 # to git grep and throw an error. :-( | 1808 # to git grep and throw an error. :-( |
| 1805 if not args or re.match('(-h|--help)$', args[0]): | 1809 if not args or re.match('(-h|--help)$', args[0]): |
| 1806 print >> sys.stderr, ( | 1810 print( |
| 1807 'Usage: gclient grep [-j <N>] git-grep-args...\n\n' | 1811 'Usage: gclient grep [-j <N>] git-grep-args...\n\n' |
| 1808 'Example: "gclient grep -j10 -A2 RefCountedBase" runs\n"git grep ' | 1812 'Example: "gclient grep -j10 -A2 RefCountedBase" runs\n"git grep ' |
| 1809 '-A2 RefCountedBase" on each of gclient\'s git\nrepos with up to ' | 1813 '-A2 RefCountedBase" on each of gclient\'s git\nrepos with up to ' |
| 1810 '10 jobs.\n\nBonus: page output by appending "|& less -FRSX" to the' | 1814 '10 jobs.\n\nBonus: page output by appending "|& less -FRSX" to the' |
| 1811 ' end of your query.' | 1815 ' end of your query.', |
| 1812 ) | 1816 file=sys.stderr) |
| 1813 return 1 | 1817 return 1 |
| 1814 | 1818 |
| 1815 jobs_arg = ['--jobs=1'] | 1819 jobs_arg = ['--jobs=1'] |
| 1816 if re.match(r'(-j|--jobs=)\d+$', args[0]): | 1820 if re.match(r'(-j|--jobs=)\d+$', args[0]): |
| 1817 jobs_arg, args = args[:1], args[1:] | 1821 jobs_arg, args = args[:1], args[1:] |
| 1818 elif re.match(r'(-j|--jobs)$', args[0]): | 1822 elif re.match(r'(-j|--jobs)$', args[0]): |
| 1819 jobs_arg, args = args[:2], args[2:] | 1823 jobs_arg, args = args[:2], args[2:] |
| 1820 | 1824 |
| 1821 return CMDrecurse( | 1825 return CMDrecurse( |
| 1822 parser, | 1826 parser, |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 | 2174 |
| 2171 | 2175 |
| 2172 def CMDhookinfo(parser, args): | 2176 def CMDhookinfo(parser, args): |
| 2173 """Outputs the hooks that would be run by `gclient runhooks`.""" | 2177 """Outputs the hooks that would be run by `gclient runhooks`.""" |
| 2174 (options, args) = parser.parse_args(args) | 2178 (options, args) = parser.parse_args(args) |
| 2175 options.force = True | 2179 options.force = True |
| 2176 client = GClient.LoadCurrentConfig(options) | 2180 client = GClient.LoadCurrentConfig(options) |
| 2177 if not client: | 2181 if not client: |
| 2178 raise gclient_utils.Error('client not configured; see \'gclient config\'') | 2182 raise gclient_utils.Error('client not configured; see \'gclient config\'') |
| 2179 client.RunOnDeps(None, []) | 2183 client.RunOnDeps(None, []) |
| 2180 print '; '.join(' '.join(hook) for hook in client.GetHooks(options)) | 2184 print('; '.join(' '.join(hook) for hook in client.GetHooks(options))) |
| 2181 return 0 | 2185 return 0 |
| 2182 | 2186 |
| 2183 | 2187 |
| 2184 def CMDverify(parser, args): | 2188 def CMDverify(parser, args): |
| 2185 """Verifies the DEPS file deps are only from allowed_hosts.""" | 2189 """Verifies the DEPS file deps are only from allowed_hosts.""" |
| 2186 (options, args) = parser.parse_args(args) | 2190 (options, args) = parser.parse_args(args) |
| 2187 client = GClient.LoadCurrentConfig(options) | 2191 client = GClient.LoadCurrentConfig(options) |
| 2188 if not client: | 2192 if not client: |
| 2189 raise gclient_utils.Error('client not configured; see \'gclient config\'') | 2193 raise gclient_utils.Error('client not configured; see \'gclient config\'') |
| 2190 client.RunOnDeps(None, []) | 2194 client.RunOnDeps(None, []) |
| 2191 # Look at each first-level dependency of this gclient only. | 2195 # Look at each first-level dependency of this gclient only. |
| 2192 for dep in client.dependencies: | 2196 for dep in client.dependencies: |
| 2193 bad_deps = dep.findDepsFromNotAllowedHosts() | 2197 bad_deps = dep.findDepsFromNotAllowedHosts() |
| 2194 if not bad_deps: | 2198 if not bad_deps: |
| 2195 continue | 2199 continue |
| 2196 print "There are deps from not allowed hosts in file %s" % dep.deps_file | 2200 print("There are deps from not allowed hosts in file %s" % dep.deps_file) |
| 2197 for bad_dep in bad_deps: | 2201 for bad_dep in bad_deps: |
| 2198 print "\t%s at %s" % (bad_dep.name, bad_dep.url) | 2202 print("\t%s at %s" % (bad_dep.name, bad_dep.url)) |
| 2199 print "allowed_hosts:", ', '.join(dep.allowed_hosts) | 2203 print("allowed_hosts:", ', '.join(dep.allowed_hosts)) |
| 2200 sys.stdout.flush() | 2204 sys.stdout.flush() |
| 2201 raise gclient_utils.Error( | 2205 raise gclient_utils.Error( |
| 2202 'dependencies from disallowed hosts; check your DEPS file.') | 2206 'dependencies from disallowed hosts; check your DEPS file.') |
| 2203 return 0 | 2207 return 0 |
| 2204 | 2208 |
| 2205 class OptionParser(optparse.OptionParser): | 2209 class OptionParser(optparse.OptionParser): |
| 2206 gclientfile_default = os.environ.get('GCLIENT_FILE', '.gclient') | 2210 gclientfile_default = os.environ.get('GCLIENT_FILE', '.gclient') |
| 2207 | 2211 |
| 2208 def __init__(self, **kwargs): | 2212 def __init__(self, **kwargs): |
| 2209 optparse.OptionParser.__init__( | 2213 optparse.OptionParser.__init__( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2282 # operations. Python as a strong tendency to buffer sys.stdout. | 2286 # operations. Python as a strong tendency to buffer sys.stdout. |
| 2283 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 2287 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
| 2284 # Make stdout annotated with the thread ids. | 2288 # Make stdout annotated with the thread ids. |
| 2285 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout) | 2289 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout) |
| 2286 | 2290 |
| 2287 | 2291 |
| 2288 def main(argv): | 2292 def main(argv): |
| 2289 """Doesn't parse the arguments here, just find the right subcommand to | 2293 """Doesn't parse the arguments here, just find the right subcommand to |
| 2290 execute.""" | 2294 execute.""" |
| 2291 if sys.hexversion < 0x02060000: | 2295 if sys.hexversion < 0x02060000: |
| 2292 print >> sys.stderr, ( | 2296 print( |
| 2293 '\nYour python version %s is unsupported, please upgrade.\n' % | 2297 '\nYour python version %s is unsupported, please upgrade.\n' % |
| 2294 sys.version.split(' ', 1)[0]) | 2298 sys.version.split(' ', 1)[0], |
| 2299 file=sys.stderr) |
| 2295 return 2 | 2300 return 2 |
| 2296 if not sys.executable: | 2301 if not sys.executable: |
| 2297 print >> sys.stderr, ( | 2302 print( |
| 2298 '\nPython cannot find the location of it\'s own executable.\n') | 2303 '\nPython cannot find the location of it\'s own executable.\n', |
| 2304 file=sys.stderr) |
| 2299 return 2 | 2305 return 2 |
| 2300 fix_encoding.fix_encoding() | 2306 fix_encoding.fix_encoding() |
| 2301 disable_buffering() | 2307 disable_buffering() |
| 2302 colorama.init() | 2308 colorama.init() |
| 2303 dispatcher = subcommand.CommandDispatcher(__name__) | 2309 dispatcher = subcommand.CommandDispatcher(__name__) |
| 2304 try: | 2310 try: |
| 2305 return dispatcher.execute(OptionParser(), argv) | 2311 return dispatcher.execute(OptionParser(), argv) |
| 2306 except KeyboardInterrupt: | 2312 except KeyboardInterrupt: |
| 2307 gclient_utils.GClientChildren.KillAllRemainingChildren() | 2313 gclient_utils.GClientChildren.KillAllRemainingChildren() |
| 2308 raise | 2314 raise |
| 2309 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 2315 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 2310 print >> sys.stderr, 'Error: %s' % str(e) | 2316 print('Error: %s' % str(e), file=sys.stderr) |
| 2311 return 1 | 2317 return 1 |
| 2312 finally: | 2318 finally: |
| 2313 gclient_utils.PrintWarnings() | 2319 gclient_utils.PrintWarnings() |
| 2314 return 0 | 2320 return 0 |
| 2315 | 2321 |
| 2316 | 2322 |
| 2317 if '__main__' == __name__: | 2323 if '__main__' == __name__: |
| 2318 try: | 2324 try: |
| 2319 sys.exit(main(sys.argv[1:])) | 2325 sys.exit(main(sys.argv[1:])) |
| 2320 except KeyboardInterrupt: | 2326 except KeyboardInterrupt: |
| 2321 sys.stderr.write('interrupted\n') | 2327 sys.stderr.write('interrupted\n') |
| 2322 sys.exit(1) | 2328 sys.exit(1) |
| 2323 | 2329 |
| 2324 # vim: ts=2:sw=2:tw=80:et: | 2330 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |