| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 # TODO(iannucci): assert that the tags are in the remote fetch refspec | 57 # TODO(iannucci): assert that the tags are in the remote fetch refspec |
| 58 fetch_args = ['--all'] | 58 fetch_args = ['--all'] |
| 59 else: | 59 else: |
| 60 fetch_args.append('--multiple') | 60 fetch_args.append('--multiple') |
| 61 fetch_args.extend(remotes) | 61 fetch_args.extend(remotes) |
| 62 # TODO(iannucci): Should we fetch git-svn? | 62 # TODO(iannucci): Should we fetch git-svn? |
| 63 | 63 |
| 64 if not fetch_args: # pragma: no cover | 64 if not fetch_args: # pragma: no cover |
| 65 print 'Nothing to fetch.' | 65 print 'Nothing to fetch.' |
| 66 else: | 66 else: |
| 67 out, err = git.run_with_stderr('fetch', *fetch_args) | 67 git.run_with_stderr('fetch', *fetch_args, stdout=sys.stdout, |
| 68 for data, stream in zip((out, err), (sys.stdout, sys.stderr)): | 68 stderr=sys.stderr) |
| 69 if data: | |
| 70 print >> stream, data | |
| 71 | 69 |
| 72 | 70 |
| 73 def remove_empty_branches(branch_tree): | 71 def remove_empty_branches(branch_tree): |
| 74 tag_set = git.tags() | 72 tag_set = git.tags() |
| 75 ensure_root_checkout = git.once(lambda: git.run('checkout', git.root())) | 73 ensure_root_checkout = git.once(lambda: git.run('checkout', git.root())) |
| 76 | 74 |
| 77 deletions = set() | 75 deletions = set() |
| 78 downstreams = collections.defaultdict(list) | 76 downstreams = collections.defaultdict(list) |
| 79 for branch, parent in git.topo_iter(branch_tree, top_down=False): | 77 for branch, parent in git.topo_iter(branch_tree, top_down=False): |
| 80 downstreams[parent].append(branch) | 78 downstreams[parent].append(branch) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 % (return_branch, root_branch) | 242 % (return_branch, root_branch) |
| 245 ) | 243 ) |
| 246 git.run('checkout', root_branch) | 244 git.run('checkout', root_branch) |
| 247 git.set_config(STARTING_BRANCH_KEY, '') | 245 git.set_config(STARTING_BRANCH_KEY, '') |
| 248 | 246 |
| 249 return retcode | 247 return retcode |
| 250 | 248 |
| 251 | 249 |
| 252 if __name__ == '__main__': # pragma: no cover | 250 if __name__ == '__main__': # pragma: no cover |
| 253 sys.exit(main(sys.argv[1:])) | 251 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |