Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: git_rebase_update.py

Issue 1497313002: Fix multi-rename empty branch detection. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@add_better_error_to_rp
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 def remove_empty_branches(branch_tree): 86 def remove_empty_branches(branch_tree):
87 tag_set = git.tags() 87 tag_set = git.tags()
88 ensure_root_checkout = git.once(lambda: git.run('checkout', git.root())) 88 ensure_root_checkout = git.once(lambda: git.run('checkout', git.root()))
89 89
90 deletions = {} 90 deletions = {}
91 reparents = {} 91 reparents = {}
92 downstreams = collections.defaultdict(list) 92 downstreams = collections.defaultdict(list)
93 for branch, parent in git.topo_iter(branch_tree, top_down=False): 93 for branch, parent in git.topo_iter(branch_tree, top_down=False):
94 downstreams[parent].append(branch) 94 downstreams[parent].append(branch)
95 95
96 # If branch and parent have the same state, then branch has to be marked 96 # If branch and parent have the same tree, then branch has to be marked
97 # for deletion and its children and grand-children reparented to parent. 97 # for deletion and its children and grand-children reparented to parent.
98 if git.hash_one(branch) == git.hash_one(parent): 98 if git.hash_one(branch+":") == git.hash_one(parent+":"):
99 ensure_root_checkout() 99 ensure_root_checkout()
100 100
101 logging.debug('branch %s merged to %s', branch, parent) 101 logging.debug('branch %s merged to %s', branch, parent)
102 102
103 # Mark branch for deletion while remembering the ordering, then add all 103 # Mark branch for deletion while remembering the ordering, then add all
104 # its children as grand-children of its parent and record reparenting 104 # its children as grand-children of its parent and record reparenting
105 # information if necessary. 105 # information if necessary.
106 deletions[branch] = len(deletions) 106 deletions[branch] = len(deletions)
107 107
108 for down in downstreams[branch]: 108 for down in downstreams[branch]:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 return retcode 320 return retcode
321 321
322 322
323 if __name__ == '__main__': # pragma: no cover 323 if __name__ == '__main__': # pragma: no cover
324 try: 324 try:
325 sys.exit(main()) 325 sys.exit(main())
326 except KeyboardInterrupt: 326 except KeyboardInterrupt:
327 sys.stderr.write('interrupted\n') 327 sys.stderr.write('interrupted\n')
328 sys.exit(1) 328 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698