OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """ | 6 """ |
7 Tool to update all branches to have the latest changes from their upstreams. | 7 Tool to update all branches to have the latest changes from their upstreams. |
8 """ | 8 """ |
9 | 9 |
10 import argparse | 10 import argparse |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 return return_branch, workdir | 43 return return_branch, workdir |
44 | 44 |
45 | 45 |
46 def fetch_remotes(branch_tree): | 46 def fetch_remotes(branch_tree): |
47 """Fetches all remotes which are needed to update |branch_tree|.""" | 47 """Fetches all remotes which are needed to update |branch_tree|.""" |
48 fetch_tags = False | 48 fetch_tags = False |
49 remotes = set() | 49 remotes = set() |
50 tag_set = git.tags() | 50 tag_set = git.tags() |
51 fetchspec_map = {} | 51 fetchspec_map = {} |
52 all_fetchspec_configs = git.run( | 52 all_fetchspec_configs = git.config_regexp(r'^remote\..*\.fetch') |
53 'config', '--get-regexp', r'^remote\..*\.fetch').strip() | 53 for fetchspec_config in all_fetchspec_configs: |
54 for fetchspec_config in all_fetchspec_configs.splitlines(): | |
55 key, _, fetchspec = fetchspec_config.partition(' ') | 54 key, _, fetchspec = fetchspec_config.partition(' ') |
56 dest_spec = fetchspec.partition(':')[2] | 55 dest_spec = fetchspec.partition(':')[2] |
57 remote_name = key.split('.')[1] | 56 remote_name = key.split('.')[1] |
58 fetchspec_map[dest_spec] = remote_name | 57 fetchspec_map[dest_spec] = remote_name |
59 for parent in branch_tree.itervalues(): | 58 for parent in branch_tree.itervalues(): |
60 if parent in tag_set: | 59 if parent in tag_set: |
61 fetch_tags = True | 60 fetch_tags = True |
62 else: | 61 else: |
63 full_ref = git.run('rev-parse', '--symbolic-full-name', parent) | 62 full_ref = git.run('rev-parse', '--symbolic-full-name', parent) |
64 for dest_spec, remote_name in fetchspec_map.iteritems(): | 63 for dest_spec, remote_name in fetchspec_map.iteritems(): |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 318 |
320 return retcode | 319 return retcode |
321 | 320 |
322 | 321 |
323 if __name__ == '__main__': # pragma: no cover | 322 if __name__ == '__main__': # pragma: no cover |
324 try: | 323 try: |
325 sys.exit(main()) | 324 sys.exit(main()) |
326 except KeyboardInterrupt: | 325 except KeyboardInterrupt: |
327 sys.stderr.write('interrupted\n') | 326 sys.stderr.write('interrupted\n') |
328 sys.exit(1) | 327 sys.exit(1) |
OLD | NEW |