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

Side by Side Diff: git_rebase_update.py

Issue 228353003: Fix empty section appearing in git config for every rebase-update. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years, 8 months 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 10 matching lines...) Expand all
21 STARTING_BRANCH_KEY = 'depot-tools.rebase-update.starting-branch' 21 STARTING_BRANCH_KEY = 'depot-tools.rebase-update.starting-branch'
22 22
23 23
24 def find_return_branch(): 24 def find_return_branch():
25 """Finds the branch which we should return to after rebase-update completes. 25 """Finds the branch which we should return to after rebase-update completes.
26 26
27 This value may persist across multiple invocations of rebase-update, if 27 This value may persist across multiple invocations of rebase-update, if
28 rebase-update runs into a conflict mid-way. 28 rebase-update runs into a conflict mid-way.
29 """ 29 """
30 return_branch = git.config(STARTING_BRANCH_KEY) 30 return_branch = git.config(STARTING_BRANCH_KEY)
31 if return_branch is None: 31 if not return_branch:
32 return_branch = git.current_branch() 32 return_branch = git.current_branch()
33 if return_branch != 'HEAD': 33 if return_branch != 'HEAD':
34 git.set_config(STARTING_BRANCH_KEY, return_branch) 34 git.set_config(STARTING_BRANCH_KEY, return_branch)
35 35
36 return return_branch 36 return return_branch
37 37
38 38
39 def fetch_remotes(branch_tree): 39 def fetch_remotes(branch_tree):
40 """Fetches all remotes which are needed to update |branch_tree|.""" 40 """Fetches all remotes which are needed to update |branch_tree|."""
41 fetch_tags = False 41 fetch_tags = False
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 git.run('checkout', return_branch) 237 git.run('checkout', return_branch)
238 git.thaw() 238 git.thaw()
239 else: 239 else:
240 root_branch = git.root() 240 root_branch = git.root()
241 if return_branch != 'HEAD': 241 if return_branch != 'HEAD':
242 print ( 242 print (
243 "%r was merged with its parent, checking out %r instead." 243 "%r was merged with its parent, checking out %r instead."
244 % (return_branch, root_branch) 244 % (return_branch, root_branch)
245 ) 245 )
246 git.run('checkout', root_branch) 246 git.run('checkout', root_branch)
247 git.del_config(STARTING_BRANCH_KEY) 247 git.set_config(STARTING_BRANCH_KEY, '')
248 248
249 return retcode 249 return retcode
250 250
251 251
252 if __name__ == '__main__': # pragma: no cover 252 if __name__ == '__main__': # pragma: no cover
253 sys.exit(main(sys.argv[1:])) 253 sys.exit(main(sys.argv[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