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 | 7 |
8 Files | 8 Files |
9 .gclient : Current client configuration, written by 'config' command. | 9 .gclient : Current client configuration, written by 'config' command. |
10 Format is a Python script defining 'solutions', a list whose | 10 Format is a Python script defining 'solutions', a list whose |
(...skipping 1062 matching lines...) Loading... | |
1073 for d in self.root.subtree(False): | 1073 for d in self.root.subtree(False): |
1074 if self._options.actual: | 1074 if self._options.actual: |
1075 entries[d.name] = GetURLAndRev(d) | 1075 entries[d.name] = GetURLAndRev(d) |
1076 else: | 1076 else: |
1077 entries[d.name] = d.parsed_url | 1077 entries[d.name] = d.parsed_url |
1078 keys = sorted(entries.keys()) | 1078 keys = sorted(entries.keys()) |
1079 for x in keys: | 1079 for x in keys: |
1080 print('%s: %s' % (x, entries[x])) | 1080 print('%s: %s' % (x, entries[x])) |
1081 logging.info(str(self)) | 1081 logging.info(str(self)) |
1082 | 1082 |
1083 def HookInfo(self): | |
1084 work_queue = gclient_utils.ExecutionQueue(self._options.jobs, None) | |
1085 for s in self.dependencies: | |
1086 work_queue.enqueue(s) | |
1087 work_queue.flush({}, None, [], options=self._options) | |
1088 hooks = [] | |
1089 def _f(*args, **kwargs): | |
1090 cwd = kwargs['cwd'][len(self.root.root_dir)+1:] | |
1091 if not cwd: | |
1092 cwd = '.' | |
1093 hooks.append({'command': list(*args), 'cwd': cwd}) | |
1094 tmp = gclient_utils.CheckCallAndFilterAndHeader | |
1095 gclient_utils.CheckCallAndFilterAndHeader = _f | |
M-A Ruel
2012/01/28 02:15:18
:/ I'd rather have you pass an argument to RunHook
szager
2012/01/30 18:47:07
OK, less monkey more patch.
| |
1096 self.RunHooksRecursively(self._options) | |
1097 gclient_utils.CheckCallAndFilterAndHeader = tmp | |
1098 return hooks | |
1099 | |
1083 def ParseDepsFile(self): | 1100 def ParseDepsFile(self): |
1084 """No DEPS to parse for a .gclient file.""" | 1101 """No DEPS to parse for a .gclient file.""" |
1085 raise gclient_utils.Error('Internal error') | 1102 raise gclient_utils.Error('Internal error') |
1086 | 1103 |
1087 @property | 1104 @property |
1088 def root_dir(self): | 1105 def root_dir(self): |
1089 """Root directory of gclient checkout.""" | 1106 """Root directory of gclient checkout.""" |
1090 return self._root_dir | 1107 return self._root_dir |
1091 | 1108 |
1092 @property | 1109 @property |
(...skipping 323 matching lines...) Loading... | |
1416 'version of all repositories to reproduce the tree, ' | 1433 'version of all repositories to reproduce the tree, ' |
1417 'implies -a') | 1434 'implies -a') |
1418 (options, args) = parser.parse_args(args) | 1435 (options, args) = parser.parse_args(args) |
1419 client = GClient.LoadCurrentConfig(options) | 1436 client = GClient.LoadCurrentConfig(options) |
1420 if not client: | 1437 if not client: |
1421 raise gclient_utils.Error('client not configured; see \'gclient config\'') | 1438 raise gclient_utils.Error('client not configured; see \'gclient config\'') |
1422 client.PrintRevInfo() | 1439 client.PrintRevInfo() |
1423 return 0 | 1440 return 0 |
1424 | 1441 |
1425 | 1442 |
1443 def CMDhookinfo(parser, args): | |
1444 """Output the hooks that would be run by `gclient runhooks`""" | |
1445 | |
1446 (options, args) = parser.parse_args(args) | |
1447 client = GClient.LoadCurrentConfig(options) | |
1448 if not client: | |
1449 raise gclient_utils.Error('client not configured; see \'gclient config\'') | |
1450 print client.HookInfo() | |
1451 return 0 | |
1452 | |
1453 | |
1426 def Command(name): | 1454 def Command(name): |
1427 return getattr(sys.modules[__name__], 'CMD' + name, None) | 1455 return getattr(sys.modules[__name__], 'CMD' + name, None) |
1428 | 1456 |
1429 | 1457 |
1430 def CMDhelp(parser, args): | 1458 def CMDhelp(parser, args): |
1431 """Prints list of commands or help for a specific command.""" | 1459 """Prints list of commands or help for a specific command.""" |
1432 (_, args) = parser.parse_args(args) | 1460 (_, args) = parser.parse_args(args) |
1433 if len(args) == 1: | 1461 if len(args) == 1: |
1434 return Main(args + ['--help']) | 1462 return Main(args + ['--help']) |
1435 parser.print_help() | 1463 parser.print_help() |
(...skipping 96 matching lines...) Loading... | |
1532 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1560 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
1533 print >> sys.stderr, 'Error: %s' % str(e) | 1561 print >> sys.stderr, 'Error: %s' % str(e) |
1534 return 1 | 1562 return 1 |
1535 | 1563 |
1536 | 1564 |
1537 if '__main__' == __name__: | 1565 if '__main__' == __name__: |
1538 fix_encoding.fix_encoding() | 1566 fix_encoding.fix_encoding() |
1539 sys.exit(Main(sys.argv[1:])) | 1567 sys.exit(Main(sys.argv[1:])) |
1540 | 1568 |
1541 # vim: ts=2:sw=2:tw=80:et: | 1569 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |