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

Side by Side Diff: gclient.py

Issue 1789713004: Log the location where we start to search .gclient for (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix Created 4 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/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 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1371 return client 1371 return client
1372 1372
1373 @staticmethod 1373 @staticmethod
1374 def LoadCurrentConfig(options): 1374 def LoadCurrentConfig(options):
1375 """Searches for and loads a .gclient file relative to the current working 1375 """Searches for and loads a .gclient file relative to the current working
1376 dir. Returns a GClient object.""" 1376 dir. Returns a GClient object."""
1377 if options.spec: 1377 if options.spec:
1378 client = GClient('.', options) 1378 client = GClient('.', options)
1379 client.SetConfig(options.spec) 1379 client.SetConfig(options.spec)
1380 else: 1380 else:
1381 if options.verbose:
1382 print('Looking for %s starting from %s\n' % (
1383 options.config_filename, os.getcwd()))
1381 path = gclient_utils.FindGclientRoot(os.getcwd(), options.config_filename) 1384 path = gclient_utils.FindGclientRoot(os.getcwd(), options.config_filename)
1382 if not path: 1385 if not path:
1383 return None 1386 return None
1384 client = GClient(path, options) 1387 client = GClient(path, options)
1385 client.SetConfig(gclient_utils.FileRead( 1388 client.SetConfig(gclient_utils.FileRead(
1386 os.path.join(path, options.config_filename))) 1389 os.path.join(path, options.config_filename)))
1387 client = client.MigrateConfigToGit(path, options) 1390 client = client.MigrateConfigToGit(path, options)
1388 1391
1389 if (options.revisions and 1392 if (options.revisions and
1390 len(client.dependencies) > 1 and 1393 len(client.dependencies) > 1 and
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1689 entries[d.name] = d.parsed_url 1692 entries[d.name] = d.parsed_url
1690 keys = sorted(entries.keys()) 1693 keys = sorted(entries.keys())
1691 for x in keys: 1694 for x in keys:
1692 print('%s: %s' % (x, entries[x])) 1695 print('%s: %s' % (x, entries[x]))
1693 logging.info(str(self)) 1696 logging.info(str(self))
1694 1697
1695 def ParseDepsFile(self): 1698 def ParseDepsFile(self):
1696 """No DEPS to parse for a .gclient file.""" 1699 """No DEPS to parse for a .gclient file."""
1697 raise gclient_utils.Error('Internal error') 1700 raise gclient_utils.Error('Internal error')
1698 1701
1702 def PrintLocationAndContents(self):
1703 # Print out the .gclient file. This is longer than if we just printed the
1704 # client dict, but more legible, and it might contain helpful comments.
1705 print('Loaded .gclient config in %s:\n%s' % (
1706 self.root_dir, self.config_content))
1707
1699 @property 1708 @property
1700 def root_dir(self): 1709 def root_dir(self):
1701 """Root directory of gclient checkout.""" 1710 """Root directory of gclient checkout."""
1702 return self._root_dir 1711 return self._root_dir
1703 1712
1704 @property 1713 @property
1705 def enforced_os(self): 1714 def enforced_os(self):
1706 """What deps_os entries that are to be parsed.""" 1715 """What deps_os entries that are to be parsed."""
1707 return self._enforced_os 1716 return self._enforced_os
1708 1717
(...skipping 22 matching lines...) Expand all
1731 """ 1740 """
1732 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', 1741 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST',
1733 help='override deps for the specified (comma-separated) ' 1742 help='override deps for the specified (comma-separated) '
1734 'platform(s); \'all\' will process all deps_os ' 1743 'platform(s); \'all\' will process all deps_os '
1735 'references') 1744 'references')
1736 (options, args) = parser.parse_args(args) 1745 (options, args) = parser.parse_args(args)
1737 client = GClient.LoadCurrentConfig(options) 1746 client = GClient.LoadCurrentConfig(options)
1738 if not client: 1747 if not client:
1739 raise gclient_utils.Error('client not configured; see \'gclient config\'') 1748 raise gclient_utils.Error('client not configured; see \'gclient config\'')
1740 if options.verbose: 1749 if options.verbose:
1741 # Print out the .gclient file. This is longer than if we just printed the 1750 client.PrintLocationAndContents()
1742 # client dict, but more legible, and it might contain helpful comments.
1743 print(client.config_content)
1744 return client.RunOnDeps('cleanup', args) 1751 return client.RunOnDeps('cleanup', args)
1745 1752
1746 1753
1747 @subcommand.usage('[command] [args ...]') 1754 @subcommand.usage('[command] [args ...]')
1748 def CMDrecurse(parser, args): 1755 def CMDrecurse(parser, args):
1749 """Operates [command args ...] on all the dependencies. 1756 """Operates [command args ...] on all the dependencies.
1750 1757
1751 Runs a shell command on all entries. 1758 Runs a shell command on all entries.
1752 Sets GCLIENT_DEP_PATH enviroment variable as the dep's relative location to 1759 Sets GCLIENT_DEP_PATH enviroment variable as the dep's relative location to
1753 root directory of the checkout. 1760 root directory of the checkout.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 'platform(s); \'all\' will process all deps_os ' 1929 'platform(s); \'all\' will process all deps_os '
1923 'references') 1930 'references')
1924 parser.remove_option('--jobs') 1931 parser.remove_option('--jobs')
1925 (options, args) = parser.parse_args(args) 1932 (options, args) = parser.parse_args(args)
1926 # Force jobs to 1 so the stdout is not annotated with the thread ids 1933 # Force jobs to 1 so the stdout is not annotated with the thread ids
1927 options.jobs = 1 1934 options.jobs = 1
1928 client = GClient.LoadCurrentConfig(options) 1935 client = GClient.LoadCurrentConfig(options)
1929 if not client: 1936 if not client:
1930 raise gclient_utils.Error('client not configured; see \'gclient config\'') 1937 raise gclient_utils.Error('client not configured; see \'gclient config\'')
1931 if options.verbose: 1938 if options.verbose:
1932 # Print out the .gclient file. This is longer than if we just printed the 1939 client.PrintLocationAndContents()
1933 # client dict, but more legible, and it might contain helpful comments.
1934 print(client.config_content)
1935 return client.RunOnDeps('pack', args) 1940 return client.RunOnDeps('pack', args)
1936 1941
1937 1942
1938 def CMDstatus(parser, args): 1943 def CMDstatus(parser, args):
1939 """Shows modification status for every dependencies.""" 1944 """Shows modification status for every dependencies."""
1940 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', 1945 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST',
1941 help='override deps for the specified (comma-separated) ' 1946 help='override deps for the specified (comma-separated) '
1942 'platform(s); \'all\' will process all deps_os ' 1947 'platform(s); \'all\' will process all deps_os '
1943 'references') 1948 'references')
1944 (options, args) = parser.parse_args(args) 1949 (options, args) = parser.parse_args(args)
1945 client = GClient.LoadCurrentConfig(options) 1950 client = GClient.LoadCurrentConfig(options)
1946 if not client: 1951 if not client:
1947 raise gclient_utils.Error('client not configured; see \'gclient config\'') 1952 raise gclient_utils.Error('client not configured; see \'gclient config\'')
1948 if options.verbose: 1953 if options.verbose:
1949 # Print out the .gclient file. This is longer than if we just printed the 1954 client.PrintLocationAndContents()
1950 # client dict, but more legible, and it might contain helpful comments.
1951 print(client.config_content)
1952 return client.RunOnDeps('status', args) 1955 return client.RunOnDeps('status', args)
1953 1956
1954 1957
1955 @subcommand.epilog("""Examples: 1958 @subcommand.epilog("""Examples:
1956 gclient sync 1959 gclient sync
1957 update files from SCM according to current configuration, 1960 update files from SCM according to current configuration,
1958 *for modules which have changed since last update or sync* 1961 *for modules which have changed since last update or sync*
1959 gclient sync --force 1962 gclient sync --force
1960 update files from SCM according to current configuration, for 1963 update files from SCM according to current configuration, for
1961 all modules (useful for recovering files deleted from local copy) 1964 all modules (useful for recovering files deleted from local copy)
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2054 client = GClient.LoadCurrentConfig(options) 2057 client = GClient.LoadCurrentConfig(options)
2055 2058
2056 if not client: 2059 if not client:
2057 raise gclient_utils.Error('client not configured; see \'gclient config\'') 2060 raise gclient_utils.Error('client not configured; see \'gclient config\'')
2058 2061
2059 if options.revisions and options.head: 2062 if options.revisions and options.head:
2060 # TODO(maruel): Make it a parser.error if it doesn't break any builder. 2063 # TODO(maruel): Make it a parser.error if it doesn't break any builder.
2061 print('Warning: you cannot use both --head and --revision') 2064 print('Warning: you cannot use both --head and --revision')
2062 2065
2063 if options.verbose: 2066 if options.verbose:
2064 # Print out the .gclient file. This is longer than if we just printed the 2067 client.PrintLocationAndContents()
2065 # client dict, but more legible, and it might contain helpful comments.
2066 print(client.config_content)
2067 ret = client.RunOnDeps('update', args) 2068 ret = client.RunOnDeps('update', args)
2068 if options.output_json: 2069 if options.output_json:
2069 slns = {} 2070 slns = {}
2070 for d in client.subtree(True): 2071 for d in client.subtree(True):
2071 normed = d.name.replace('\\', '/').rstrip('/') + '/' 2072 normed = d.name.replace('\\', '/').rstrip('/') + '/'
2072 slns[normed] = { 2073 slns[normed] = {
2073 'revision': d.got_revision, 2074 'revision': d.got_revision,
2074 'scm': d.used_scm.name if d.used_scm else None, 2075 'scm': d.used_scm.name if d.used_scm else None,
2075 'url': str(d.url) if d.url else None, 2076 'url': str(d.url) if d.url else None,
2076 } 2077 }
2077 with open(options.output_json, 'wb') as f: 2078 with open(options.output_json, 'wb') as f:
2078 json.dump({'solutions': slns}, f) 2079 json.dump({'solutions': slns}, f)
2079 return ret 2080 return ret
2080 2081
2081 2082
2082 CMDupdate = CMDsync 2083 CMDupdate = CMDsync
2083 2084
2084 2085
2085 def CMDdiff(parser, args): 2086 def CMDdiff(parser, args):
2086 """Displays local diff for every dependencies.""" 2087 """Displays local diff for every dependencies."""
2087 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', 2088 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST',
2088 help='override deps for the specified (comma-separated) ' 2089 help='override deps for the specified (comma-separated) '
2089 'platform(s); \'all\' will process all deps_os ' 2090 'platform(s); \'all\' will process all deps_os '
2090 'references') 2091 'references')
2091 (options, args) = parser.parse_args(args) 2092 (options, args) = parser.parse_args(args)
2092 client = GClient.LoadCurrentConfig(options) 2093 client = GClient.LoadCurrentConfig(options)
2093 if not client: 2094 if not client:
2094 raise gclient_utils.Error('client not configured; see \'gclient config\'') 2095 raise gclient_utils.Error('client not configured; see \'gclient config\'')
2095 if options.verbose: 2096 if options.verbose:
2096 # Print out the .gclient file. This is longer than if we just printed the 2097 client.PrintLocationAndContents()
2097 # client dict, but more legible, and it might contain helpful comments.
2098 print(client.config_content)
2099 return client.RunOnDeps('diff', args) 2098 return client.RunOnDeps('diff', args)
2100 2099
2101 2100
2102 def CMDrevert(parser, args): 2101 def CMDrevert(parser, args):
2103 """Reverts all modifications in every dependencies. 2102 """Reverts all modifications in every dependencies.
2104 2103
2105 That's the nuclear option to get back to a 'clean' state. It removes anything 2104 That's the nuclear option to get back to a 'clean' state. It removes anything
2106 that shows up in svn status.""" 2105 that shows up in svn status."""
2107 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST', 2106 parser.add_option('--deps', dest='deps_os', metavar='OS_LIST',
2108 help='override deps for the specified (comma-separated) ' 2107 help='override deps for the specified (comma-separated) '
(...skipping 22 matching lines...) Expand all
2131 help='override deps for the specified (comma-separated) ' 2130 help='override deps for the specified (comma-separated) '
2132 'platform(s); \'all\' will process all deps_os ' 2131 'platform(s); \'all\' will process all deps_os '
2133 'references') 2132 'references')
2134 parser.add_option('-f', '--force', action='store_true', default=True, 2133 parser.add_option('-f', '--force', action='store_true', default=True,
2135 help='Deprecated. No effect.') 2134 help='Deprecated. No effect.')
2136 (options, args) = parser.parse_args(args) 2135 (options, args) = parser.parse_args(args)
2137 client = GClient.LoadCurrentConfig(options) 2136 client = GClient.LoadCurrentConfig(options)
2138 if not client: 2137 if not client:
2139 raise gclient_utils.Error('client not configured; see \'gclient config\'') 2138 raise gclient_utils.Error('client not configured; see \'gclient config\'')
2140 if options.verbose: 2139 if options.verbose:
2141 # Print out the .gclient file. This is longer than if we just printed the 2140 client.PrintLocationAndContents()
2142 # client dict, but more legible, and it might contain helpful comments.
2143 print(client.config_content)
2144 options.force = True 2141 options.force = True
2145 options.nohooks = False 2142 options.nohooks = False
2146 return client.RunOnDeps('runhooks', args) 2143 return client.RunOnDeps('runhooks', args)
2147 2144
2148 2145
2149 def CMDrevinfo(parser, args): 2146 def CMDrevinfo(parser, args):
2150 """Outputs revision info mapping for the client and its dependencies. 2147 """Outputs revision info mapping for the client and its dependencies.
2151 2148
2152 This allows the capture of an overall 'revision' for the source tree that 2149 This allows the capture of an overall 'revision' for the source tree that
2153 can be used to reproduce the same tree in the future. It is only useful for 2150 can be used to reproduce the same tree in the future. It is only useful for
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 2319
2323 2320
2324 if '__main__' == __name__: 2321 if '__main__' == __name__:
2325 try: 2322 try:
2326 sys.exit(main(sys.argv[1:])) 2323 sys.exit(main(sys.argv[1:]))
2327 except KeyboardInterrupt: 2324 except KeyboardInterrupt:
2328 sys.stderr.write('interrupted\n') 2325 sys.stderr.write('interrupted\n')
2329 sys.exit(1) 2326 sys.exit(1)
2330 2327
2331 # vim: ts=2:sw=2:tw=80:et: 2328 # 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