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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 stderr=sys.stderr) | 77 stderr=sys.stderr) |
78 | 78 |
79 | 79 |
80 def remove_empty_branches(branch_tree): | 80 def remove_empty_branches(branch_tree): |
81 tag_set = git.tags() | 81 tag_set = git.tags() |
82 ensure_root_checkout = git.once(lambda: git.run('checkout', git.root())) | 82 ensure_root_checkout = git.once(lambda: git.run('checkout', git.root())) |
83 | 83 |
84 deletions = set() | 84 deletions = set() |
85 downstreams = collections.defaultdict(list) | 85 downstreams = collections.defaultdict(list) |
86 for branch, parent in git.topo_iter(branch_tree, top_down=False): | 86 for branch, parent in git.topo_iter(branch_tree, top_down=False): |
| 87 if branch == 'master': |
| 88 continue |
87 downstreams[parent].append(branch) | 89 downstreams[parent].append(branch) |
88 | 90 |
89 if git.hash_one(branch) == git.hash_one(parent): | 91 if git.hash_one(branch) == git.hash_one(parent): |
90 ensure_root_checkout() | 92 ensure_root_checkout() |
91 | 93 |
92 logging.debug('branch %s merged to %s', branch, parent) | 94 logging.debug('branch %s merged to %s', branch, parent) |
93 | 95 |
94 for down in downstreams[branch]: | 96 for down in downstreams[branch]: |
95 if down in deletions: | 97 if down in deletions: |
96 continue | 98 continue |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 % (return_branch, root_branch) | 266 % (return_branch, root_branch) |
265 ) | 267 ) |
266 git.run('checkout', root_branch) | 268 git.run('checkout', root_branch) |
267 git.set_config(STARTING_BRANCH_KEY, '') | 269 git.set_config(STARTING_BRANCH_KEY, '') |
268 | 270 |
269 return retcode | 271 return retcode |
270 | 272 |
271 | 273 |
272 if __name__ == '__main__': # pragma: no cover | 274 if __name__ == '__main__': # pragma: no cover |
273 sys.exit(main(sys.argv[1:])) | 275 sys.exit(main(sys.argv[1:])) |
OLD | NEW |