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

Side by Side Diff: git_rebase_update.py

Issue 2075603002: Refactor git_common config and die (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix unintended change Created 4 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « git_map.py ('k') | git_upstream_diff.py » ('j') | 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 13 matching lines...) Expand all
24 STARTING_WORKDIR_KEY = 'depot-tools.rebase-update.starting-workdir' 24 STARTING_WORKDIR_KEY = 'depot-tools.rebase-update.starting-workdir'
25 25
26 26
27 def find_return_branch_workdir(): 27 def find_return_branch_workdir():
28 """Finds the branch and working directory which we should return to after 28 """Finds the branch and working directory which we should return to after
29 rebase-update completes. 29 rebase-update completes.
30 30
31 These values may persist across multiple invocations of rebase-update, if 31 These values may persist across multiple invocations of rebase-update, if
32 rebase-update runs into a conflict mid-way. 32 rebase-update runs into a conflict mid-way.
33 """ 33 """
34 return_branch = git.config(STARTING_BRANCH_KEY) 34 return_branch = git.get_config(STARTING_BRANCH_KEY)
35 workdir = git.config(STARTING_WORKDIR_KEY) 35 workdir = git.get_config(STARTING_WORKDIR_KEY)
36 if not return_branch: 36 if not return_branch:
37 workdir = os.getcwd() 37 workdir = os.getcwd()
38 git.set_config(STARTING_WORKDIR_KEY, workdir) 38 git.set_config(STARTING_WORKDIR_KEY, workdir)
39 return_branch = git.current_branch() 39 return_branch = git.current_branch()
40 if return_branch != 'HEAD': 40 if return_branch != 'HEAD':
41 git.set_config(STARTING_BRANCH_KEY, return_branch) 41 git.set_config(STARTING_BRANCH_KEY, return_branch)
42 42
43 return return_branch, workdir 43 return return_branch, workdir
44 44
45 45
46 def fetch_remotes(branch_tree): 46 def fetch_remotes(branch_tree):
47 """Fetches all remotes which are needed to update |branch_tree|.""" 47 """Fetches all remotes which are needed to update |branch_tree|."""
48 fetch_tags = False 48 fetch_tags = False
49 remotes = set() 49 remotes = set()
50 tag_set = git.tags() 50 tag_set = git.tags()
51 fetchspec_map = {} 51 fetchspec_map = {}
52 all_fetchspec_configs = git.config_regexp(r'^remote\..*\.fetch') 52 all_fetchspec_configs = git.get_config_regexp(r'^remote\..*\.fetch')
53 for fetchspec_config in all_fetchspec_configs: 53 for fetchspec_config in all_fetchspec_configs:
54 key, _, fetchspec = fetchspec_config.partition(' ') 54 key, _, fetchspec = fetchspec_config.partition(' ')
55 dest_spec = fetchspec.partition(':')[2] 55 dest_spec = fetchspec.partition(':')[2]
56 remote_name = key.split('.')[1] 56 remote_name = key.split('.')[1]
57 fetchspec_map[dest_spec] = remote_name 57 fetchspec_map[dest_spec] = remote_name
58 for parent in branch_tree.itervalues(): 58 for parent in branch_tree.itervalues():
59 if parent in tag_set: 59 if parent in tag_set:
60 fetch_tags = True 60 fetch_tags = True
61 else: 61 else:
62 full_ref = git.run('rev-parse', '--symbolic-full-name', parent) 62 full_ref = git.run('rev-parse', '--symbolic-full-name', parent)
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 318
319 return retcode 319 return retcode
320 320
321 321
322 if __name__ == '__main__': # pragma: no cover 322 if __name__ == '__main__': # pragma: no cover
323 try: 323 try:
324 sys.exit(main()) 324 sys.exit(main())
325 except KeyboardInterrupt: 325 except KeyboardInterrupt:
326 sys.stderr.write('interrupted\n') 326 sys.stderr.write('interrupted\n')
327 sys.exit(1) 327 sys.exit(1)
OLDNEW
« no previous file with comments | « git_map.py ('k') | git_upstream_diff.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698