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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 import urllib | 95 import urllib |
96 import urlparse | 96 import urlparse |
97 | 97 |
98 import fix_encoding | 98 import fix_encoding |
99 import gclient_scm | 99 import gclient_scm |
100 import gclient_utils | 100 import gclient_utils |
101 import git_cache | 101 import git_cache |
102 from third_party.repo.progress import Progress | 102 from third_party.repo.progress import Progress |
103 import subcommand | 103 import subcommand |
104 import subprocess2 | 104 import subprocess2 |
105 from third_party import colorama | 105 import setup_color |
106 | 106 |
107 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src.git' | 107 CHROMIUM_SRC_URL = 'https://chromium.googlesource.com/chromium/src.git' |
108 | 108 |
109 | 109 |
110 def ast_dict_index(dnode, key): | 110 def ast_dict_index(dnode, key): |
111 """Search an ast.Dict for the argument key, and return its index.""" | 111 """Search an ast.Dict for the argument key, and return its index.""" |
112 idx = [i for i in range(len(dnode.keys)) if ( | 112 idx = [i for i in range(len(dnode.keys)) if ( |
113 type(dnode.keys[i]) is ast.Str and dnode.keys[i].s == key)] | 113 type(dnode.keys[i]) is ast.Str and dnode.keys[i].s == key)] |
114 if not idx: | 114 if not idx: |
115 return -1 | 115 return -1 |
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1504 raise gclient_utils.Error('No solution specified') | 1504 raise gclient_utils.Error('No solution specified') |
1505 | 1505 |
1506 revision_overrides = {} | 1506 revision_overrides = {} |
1507 # It's unnecessary to check for revision overrides for 'recurse'. | 1507 # It's unnecessary to check for revision overrides for 'recurse'. |
1508 # Save a few seconds by not calling _EnforceRevisions() in that case. | 1508 # Save a few seconds by not calling _EnforceRevisions() in that case. |
1509 if command not in ('diff', 'recurse', 'runhooks', 'status', 'revert'): | 1509 if command not in ('diff', 'recurse', 'runhooks', 'status', 'revert'): |
1510 self._CheckConfig() | 1510 self._CheckConfig() |
1511 revision_overrides = self._EnforceRevisions() | 1511 revision_overrides = self._EnforceRevisions() |
1512 pm = None | 1512 pm = None |
1513 # Disable progress for non-tty stdout. | 1513 # Disable progress for non-tty stdout. |
1514 if (sys.stdout.isatty() and not self._options.verbose and progress): | 1514 if (setup_color.IS_TTY and not self._options.verbose and progress): |
1515 if command in ('update', 'revert'): | 1515 if command in ('update', 'revert'): |
1516 pm = Progress('Syncing projects', 1) | 1516 pm = Progress('Syncing projects', 1) |
1517 elif command == 'recurse': | 1517 elif command == 'recurse': |
1518 pm = Progress(' '.join(args), 1) | 1518 pm = Progress(' '.join(args), 1) |
1519 work_queue = gclient_utils.ExecutionQueue( | 1519 work_queue = gclient_utils.ExecutionQueue( |
1520 self._options.jobs, pm, ignore_requirements=ignore_requirements, | 1520 self._options.jobs, pm, ignore_requirements=ignore_requirements, |
1521 verbose=self._options.verbose) | 1521 verbose=self._options.verbose) |
1522 for s in self.dependencies: | 1522 for s in self.dependencies: |
1523 work_queue.enqueue(s) | 1523 work_queue.enqueue(s) |
1524 work_queue.flush(revision_overrides, command, args, options=self._options) | 1524 work_queue.flush(revision_overrides, command, args, options=self._options) |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2296 sys.version.split(' ', 1)[0], | 2296 sys.version.split(' ', 1)[0], |
2297 file=sys.stderr) | 2297 file=sys.stderr) |
2298 return 2 | 2298 return 2 |
2299 if not sys.executable: | 2299 if not sys.executable: |
2300 print( | 2300 print( |
2301 '\nPython cannot find the location of it\'s own executable.\n', | 2301 '\nPython cannot find the location of it\'s own executable.\n', |
2302 file=sys.stderr) | 2302 file=sys.stderr) |
2303 return 2 | 2303 return 2 |
2304 fix_encoding.fix_encoding() | 2304 fix_encoding.fix_encoding() |
2305 disable_buffering() | 2305 disable_buffering() |
2306 colorama.init(wrap="TERM" not in os.environ) | 2306 setup_color.init() |
2307 dispatcher = subcommand.CommandDispatcher(__name__) | 2307 dispatcher = subcommand.CommandDispatcher(__name__) |
2308 try: | 2308 try: |
2309 return dispatcher.execute(OptionParser(), argv) | 2309 return dispatcher.execute(OptionParser(), argv) |
2310 except KeyboardInterrupt: | 2310 except KeyboardInterrupt: |
2311 gclient_utils.GClientChildren.KillAllRemainingChildren() | 2311 gclient_utils.GClientChildren.KillAllRemainingChildren() |
2312 raise | 2312 raise |
2313 except (gclient_utils.Error, subprocess2.CalledProcessError) as e: | 2313 except (gclient_utils.Error, subprocess2.CalledProcessError) as e: |
2314 print('Error: %s' % str(e), file=sys.stderr) | 2314 print('Error: %s' % str(e), file=sys.stderr) |
2315 return 1 | 2315 return 1 |
2316 finally: | 2316 finally: |
2317 gclient_utils.PrintWarnings() | 2317 gclient_utils.PrintWarnings() |
2318 return 0 | 2318 return 0 |
2319 | 2319 |
2320 | 2320 |
2321 if '__main__' == __name__: | 2321 if '__main__' == __name__: |
2322 try: | 2322 try: |
2323 sys.exit(main(sys.argv[1:])) | 2323 sys.exit(main(sys.argv[1:])) |
2324 except KeyboardInterrupt: | 2324 except KeyboardInterrupt: |
2325 sys.stderr.write('interrupted\n') | 2325 sys.stderr.write('interrupted\n') |
2326 sys.exit(1) | 2326 sys.exit(1) |
2327 | 2327 |
2328 # vim: ts=2:sw=2:tw=80:et: | 2328 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |