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

Side by Side Diff: git_rebase_update.py

Issue 756223002: Change git-rebase-update to always keep branch 'master'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 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 | Annotate | Revision Log
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698