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 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1817 jobs_arg, args = args[:1], args[1:] | 1817 jobs_arg, args = args[:1], args[1:] |
1818 elif re.match(r'(-j|--jobs)$', args[0]): | 1818 elif re.match(r'(-j|--jobs)$', args[0]): |
1819 jobs_arg, args = args[:2], args[2:] | 1819 jobs_arg, args = args[:2], args[2:] |
1820 | 1820 |
1821 return CMDrecurse( | 1821 return CMDrecurse( |
1822 parser, | 1822 parser, |
1823 jobs_arg + ['--ignore', '--prepend-dir', '--no-progress', '--scm=git', | 1823 jobs_arg + ['--ignore', '--prepend-dir', '--no-progress', '--scm=git', |
1824 'git', 'grep', '--null', '--color=Always'] + args) | 1824 'git', 'grep', '--null', '--color=Always'] + args) |
1825 | 1825 |
1826 | 1826 |
| 1827 def CMDroot(parser, args): |
| 1828 """Outputs the solution root (or current dir if there isn't one).""" |
| 1829 (options, args) = parser.parse_args(args) |
| 1830 client = GClient.LoadCurrentConfig(options) |
| 1831 if client: |
| 1832 print(os.path.abspath(client.root_dir)) |
| 1833 else: |
| 1834 print(os.path.abspath('.')) |
| 1835 |
| 1836 |
1827 @subcommand.usage('[url] [safesync url]') | 1837 @subcommand.usage('[url] [safesync url]') |
1828 def CMDconfig(parser, args): | 1838 def CMDconfig(parser, args): |
1829 """Creates a .gclient file in the current directory. | 1839 """Creates a .gclient file in the current directory. |
1830 | 1840 |
1831 This specifies the configuration for further commands. After update/sync, | 1841 This specifies the configuration for further commands. After update/sync, |
1832 top-level DEPS files in each module are read to determine dependent | 1842 top-level DEPS files in each module are read to determine dependent |
1833 modules to operate on as well. If optional [url] parameter is | 1843 modules to operate on as well. If optional [url] parameter is |
1834 provided, then configuration is read from a specified Subversion server | 1844 provided, then configuration is read from a specified Subversion server |
1835 URL. | 1845 URL. |
1836 """ | 1846 """ |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 | 2309 |
2300 | 2310 |
2301 if '__main__' == __name__: | 2311 if '__main__' == __name__: |
2302 try: | 2312 try: |
2303 sys.exit(main(sys.argv[1:])) | 2313 sys.exit(main(sys.argv[1:])) |
2304 except KeyboardInterrupt: | 2314 except KeyboardInterrupt: |
2305 sys.stderr.write('interrupted\n') | 2315 sys.stderr.write('interrupted\n') |
2306 sys.exit(1) | 2316 sys.exit(1) |
2307 | 2317 |
2308 # vim: ts=2:sw=2:tw=80:et: | 2318 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |