| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 custom_hooks, deps_file, should_process): | 217 custom_hooks, deps_file, should_process): |
| 218 GClientKeywords.__init__(self) | 218 GClientKeywords.__init__(self) |
| 219 | 219 |
| 220 # These are not mutable: | 220 # These are not mutable: |
| 221 self._parent = parent | 221 self._parent = parent |
| 222 self._deps_file = deps_file | 222 self._deps_file = deps_file |
| 223 self._url = url | 223 self._url = url |
| 224 # 'managed' determines whether or not this dependency is synced/updated by | 224 # 'managed' determines whether or not this dependency is synced/updated by |
| 225 # gclient after gclient checks it out initially. The difference between | 225 # gclient after gclient checks it out initially. The difference between |
| 226 # 'managed' and 'should_process' is that the user specifies 'managed' via | 226 # 'managed' and 'should_process' is that the user specifies 'managed' via |
| 227 # the --unmanaged command-line flag or a .gclient config, where | 227 # the --managed command-line flag or a .gclient config, where |
| 228 # 'should_process' is dynamically set by gclient if it goes over its | 228 # 'should_process' is dynamically set by gclient if it goes over its |
| 229 # recursion limit and controls gclient's behavior so it does not misbehave. | 229 # recursion limit and controls gclient's behavior so it does not misbehave. |
| 230 self._managed = managed | 230 self._managed = managed |
| 231 self._should_process = should_process | 231 self._should_process = should_process |
| 232 # This is a mutable value which has the list of 'target_os' OSes listed in | 232 # This is a mutable value which has the list of 'target_os' OSes listed in |
| 233 # the current deps file. | 233 # the current deps file. |
| 234 self.local_target_os = None | 234 self.local_target_os = None |
| 235 | 235 |
| 236 # These are only set in .gclient and not in DEPS files. | 236 # These are only set in .gclient and not in DEPS files. |
| 237 self._custom_vars = custom_vars or {} | 237 self._custom_vars = custom_vars or {} |
| (...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 | 1245 |
| 1246 The .gclient file contains: | 1246 The .gclient file contains: |
| 1247 URL: %(expected_url)s (%(expected_scm)s) | 1247 URL: %(expected_url)s (%(expected_scm)s) |
| 1248 Cache mirror: %(mirror_string)s | 1248 Cache mirror: %(mirror_string)s |
| 1249 | 1249 |
| 1250 The local checkout in %(checkout_path)s reports: | 1250 The local checkout in %(checkout_path)s reports: |
| 1251 %(actual_url)s (%(actual_scm)s) | 1251 %(actual_url)s (%(actual_scm)s) |
| 1252 | 1252 |
| 1253 You should ensure that the URL listed in .gclient is correct and either change | 1253 You should ensure that the URL listed in .gclient is correct and either change |
| 1254 it or fix the checkout. If you're managing your own git checkout in | 1254 it or fix the checkout. If you're managing your own git checkout in |
| 1255 %(checkout_path)s but the URL in .gclient is for an svn repository, you probably | 1255 %(checkout_path)s but the URL in .gclient is for an svn repository, you should |
| 1256 want to set 'managed': False in .gclient. | 1256 set 'managed': False in .gclient. |
| 1257 ''' % {'checkout_path': os.path.join(self.root_dir, dep.name), | 1257 ''' % {'checkout_path': os.path.join(self.root_dir, dep.name), |
| 1258 'expected_url': dep.url, | 1258 'expected_url': dep.url, |
| 1259 'expected_scm': gclient_scm.GetScmName(dep.url), | 1259 'expected_scm': gclient_scm.GetScmName(dep.url), |
| 1260 'mirror_string' : mirror_string, | 1260 'mirror_string' : mirror_string, |
| 1261 'actual_url': actual_url, | 1261 'actual_url': actual_url, |
| 1262 'actual_scm': gclient_scm.GetScmName(actual_url)}) | 1262 'actual_scm': gclient_scm.GetScmName(actual_url)}) |
| 1263 | 1263 |
| 1264 def SetConfig(self, content): | 1264 def SetConfig(self, content): |
| 1265 assert not self.dependencies | 1265 assert not self.dependencies |
| 1266 config_dict = {} | 1266 config_dict = {} |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1293 'not specified') | 1293 'not specified') |
| 1294 | 1294 |
| 1295 deps_to_add = [] | 1295 deps_to_add = [] |
| 1296 for s in config_dict.get('solutions', []): | 1296 for s in config_dict.get('solutions', []): |
| 1297 if s.get('safesync_url'): | 1297 if s.get('safesync_url'): |
| 1298 raise gclient_utils.Error('safesync_url is not supported anymore. ' | 1298 raise gclient_utils.Error('safesync_url is not supported anymore. ' |
| 1299 'Please remove it from your .gclient file.') | 1299 'Please remove it from your .gclient file.') |
| 1300 try: | 1300 try: |
| 1301 deps_to_add.append(Dependency( | 1301 deps_to_add.append(Dependency( |
| 1302 self, s['name'], s['url'], | 1302 self, s['name'], s['url'], |
| 1303 s.get('managed', True), | 1303 s.get('managed', False), |
| 1304 s.get('custom_deps', {}), | 1304 s.get('custom_deps', {}), |
| 1305 s.get('custom_vars', {}), | 1305 s.get('custom_vars', {}), |
| 1306 s.get('custom_hooks', []), | 1306 s.get('custom_hooks', []), |
| 1307 s.get('deps_file', 'DEPS'), | 1307 s.get('deps_file', 'DEPS'), |
| 1308 True)) | 1308 True)) |
| 1309 except KeyError: | 1309 except KeyError: |
| 1310 raise gclient_utils.Error('Invalid .gclient file. Solution is ' | 1310 raise gclient_utils.Error('Invalid .gclient file. Solution is ' |
| 1311 'incomplete: %s' % s) | 1311 'incomplete: %s' % s) |
| 1312 self.add_dependencies_and_close(deps_to_add, config_dict.get('hooks', [])) | 1312 self.add_dependencies_and_close(deps_to_add, config_dict.get('hooks', [])) |
| 1313 logging.info('SetConfig() done') | 1313 logging.info('SetConfig() done') |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 ('You must specify the full solution name like --revision %s@%s\n' | 1419 ('You must specify the full solution name like --revision %s@%s\n' |
| 1420 'when you have multiple solutions setup in your .gclient file.\n' | 1420 'when you have multiple solutions setup in your .gclient file.\n' |
| 1421 'Other solutions present are: %s.') % ( | 1421 'Other solutions present are: %s.') % ( |
| 1422 client.dependencies[0].name, | 1422 client.dependencies[0].name, |
| 1423 options.revisions[0], | 1423 options.revisions[0], |
| 1424 ', '.join(s.name for s in client.dependencies[1:])), | 1424 ', '.join(s.name for s in client.dependencies[1:])), |
| 1425 file=sys.stderr) | 1425 file=sys.stderr) |
| 1426 return client | 1426 return client |
| 1427 | 1427 |
| 1428 def SetDefaultConfig(self, solution_name, deps_file, solution_url, | 1428 def SetDefaultConfig(self, solution_name, deps_file, solution_url, |
| 1429 managed=True, cache_dir=None): | 1429 managed=False, cache_dir=None): |
| 1430 self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % { | 1430 self.SetConfig(self.DEFAULT_CLIENT_FILE_TEXT % { |
| 1431 'solution_name': solution_name, | 1431 'solution_name': solution_name, |
| 1432 'solution_url': solution_url, | 1432 'solution_url': solution_url, |
| 1433 'deps_file': deps_file, | 1433 'deps_file': deps_file, |
| 1434 'managed': managed, | 1434 'managed': managed, |
| 1435 'cache_dir': cache_dir, | 1435 'cache_dir': cache_dir, |
| 1436 }) | 1436 }) |
| 1437 | 1437 |
| 1438 def _SaveEntries(self): | 1438 def _SaveEntries(self): |
| 1439 """Creates a .gclient_entries file to record the list of unique checkouts. | 1439 """Creates a .gclient_entries file to record the list of unique checkouts. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1468 exec(gclient_utils.FileRead(filename), scope) | 1468 exec(gclient_utils.FileRead(filename), scope) |
| 1469 except SyntaxError as e: | 1469 except SyntaxError as e: |
| 1470 gclient_utils.SyntaxErrorToError(filename, e) | 1470 gclient_utils.SyntaxErrorToError(filename, e) |
| 1471 return scope['entries'] | 1471 return scope['entries'] |
| 1472 | 1472 |
| 1473 def _EnforceRevisions(self): | 1473 def _EnforceRevisions(self): |
| 1474 """Checks for revision overrides.""" | 1474 """Checks for revision overrides.""" |
| 1475 revision_overrides = {} | 1475 revision_overrides = {} |
| 1476 if not self._options.revisions: | 1476 if not self._options.revisions: |
| 1477 for s in self.dependencies: | 1477 for s in self.dependencies: |
| 1478 if not s.managed and not self._options.head: | 1478 if not s.managed and not self._options.__dict__.get('head', False): |
| 1479 self._options.revisions.append('%s@unmanaged' % s.name) | 1479 self._options.revisions.append('%s@unmanaged' % s.name) |
| 1480 if not self._options.revisions: | 1480 if not self._options.revisions: |
| 1481 return revision_overrides | 1481 return revision_overrides |
| 1482 solutions_names = [s.name for s in self.dependencies] | 1482 solutions_names = [s.name for s in self.dependencies] |
| 1483 for i, revision in enumerate(self._options.revisions): | 1483 for i, revision in enumerate(self._options.revisions): |
| 1484 if not '@' in revision: | 1484 if not '@' in revision: |
| 1485 # Support for --revision 123 | 1485 # Support for --revision 123 |
| 1486 name, rev = solutions_names[i], revision | 1486 name, rev = solutions_names[i], revision |
| 1487 else: | 1487 else: |
| 1488 name, rev = revision.split('@', 1) | 1488 name, rev = revision.split('@', 1) |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 # options.output_config_file until after the (gclientfile xor spec) error | 1854 # options.output_config_file until after the (gclientfile xor spec) error |
| 1855 # check. | 1855 # check. |
| 1856 parser.remove_option('--gclientfile') | 1856 parser.remove_option('--gclientfile') |
| 1857 parser.add_option('--gclientfile', dest='output_config_file', | 1857 parser.add_option('--gclientfile', dest='output_config_file', |
| 1858 help='Specify an alternate .gclient file') | 1858 help='Specify an alternate .gclient file') |
| 1859 parser.add_option('--name', | 1859 parser.add_option('--name', |
| 1860 help='overrides the default name for the solution') | 1860 help='overrides the default name for the solution') |
| 1861 parser.add_option('--deps-file', default='DEPS', | 1861 parser.add_option('--deps-file', default='DEPS', |
| 1862 help='overrides the default name for the DEPS file for the' | 1862 help='overrides the default name for the DEPS file for the' |
| 1863 'main solutions and all sub-dependencies') | 1863 'main solutions and all sub-dependencies') |
| 1864 parser.add_option('--unmanaged', action='store_true', default=False, | 1864 parser.add_option('--managed', action='store_true', default=False, |
| 1865 help='overrides the default behavior to make it possible ' | 1865 help='overrides the default behavior to make it possible ' |
| 1866 'to have the main solution untouched by gclient ' | 1866 'to have the main solution managed by gclient ' |
| 1867 '(gclient will check out unmanaged dependencies but ' | 1867 '(gclient will always auto-sync managed solutions ' |
| 1868 'will never sync them)') | 1868 ' rather than leaving them untouched)') |
| 1869 parser.add_option('--unmanaged', action='store_true', default=True, |
| 1870 help='This flag is a no-op; unmanaged is now the default.') |
| 1869 parser.add_option('--cache-dir', | 1871 parser.add_option('--cache-dir', |
| 1870 help='(git only) Cache all git repos into this dir and do ' | 1872 help='(git only) Cache all git repos into this dir and do ' |
| 1871 'shared clones from the cache, instead of cloning ' | 1873 'shared clones from the cache, instead of cloning ' |
| 1872 'directly from the remote. (experimental)') | 1874 'directly from the remote. (experimental)') |
| 1873 parser.set_defaults(config_filename=None) | 1875 parser.set_defaults(config_filename=None) |
| 1874 (options, args) = parser.parse_args(args) | 1876 (options, args) = parser.parse_args(args) |
| 1875 if options.output_config_file: | 1877 if options.output_config_file: |
| 1876 setattr(options, 'config_filename', getattr(options, 'output_config_file')) | 1878 setattr(options, 'config_filename', getattr(options, 'output_config_file')) |
| 1877 if ((options.spec and args) or len(args) > 2 or | 1879 if ((options.spec and args) or len(args) > 2 or |
| 1878 (not options.spec and not args)): | 1880 (not options.spec and not args)): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1891 # specify an alternate relpath for the given URL. | 1893 # specify an alternate relpath for the given URL. |
| 1892 name = options.name | 1894 name = options.name |
| 1893 if not os.path.abspath(os.path.join(os.getcwd(), name)).startswith( | 1895 if not os.path.abspath(os.path.join(os.getcwd(), name)).startswith( |
| 1894 os.getcwd()): | 1896 os.getcwd()): |
| 1895 parser.error('Do not pass a relative path for --name.') | 1897 parser.error('Do not pass a relative path for --name.') |
| 1896 if any(x in ('..', '.', '/', '\\') for x in name.split(os.sep)): | 1898 if any(x in ('..', '.', '/', '\\') for x in name.split(os.sep)): |
| 1897 parser.error('Do not include relative path components in --name.') | 1899 parser.error('Do not include relative path components in --name.') |
| 1898 | 1900 |
| 1899 deps_file = options.deps_file | 1901 deps_file = options.deps_file |
| 1900 client.SetDefaultConfig(name, deps_file, base_url, | 1902 client.SetDefaultConfig(name, deps_file, base_url, |
| 1901 managed=not options.unmanaged, | 1903 managed=options.managed, |
| 1902 cache_dir=options.cache_dir) | 1904 cache_dir=options.cache_dir) |
| 1903 client.SaveConfig() | 1905 client.SaveConfig() |
| 1904 return 0 | 1906 return 0 |
| 1905 | 1907 |
| 1906 | 1908 |
| 1907 @subcommand.epilog("""Example: | 1909 @subcommand.epilog("""Example: |
| 1908 gclient pack > patch.txt | 1910 gclient pack > patch.txt |
| 1909 generate simple patch for configured client and dependences | 1911 generate simple patch for configured client and dependences |
| 1910 """) | 1912 """) |
| 1911 def CMDpack(parser, args): | 1913 def CMDpack(parser, args): |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 | 2317 |
| 2316 | 2318 |
| 2317 if '__main__' == __name__: | 2319 if '__main__' == __name__: |
| 2318 try: | 2320 try: |
| 2319 sys.exit(main(sys.argv[1:])) | 2321 sys.exit(main(sys.argv[1:])) |
| 2320 except KeyboardInterrupt: | 2322 except KeyboardInterrupt: |
| 2321 sys.stderr.write('interrupted\n') | 2323 sys.stderr.write('interrupted\n') |
| 2322 sys.exit(1) | 2324 sys.exit(1) |
| 2323 | 2325 |
| 2324 # vim: ts=2:sw=2:tw=80:et: | 2326 # vim: ts=2:sw=2:tw=80:et: |
| OLD | NEW |