| 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 |
| 11 import collections | 11 import collections |
| 12 import logging | 12 import logging |
| 13 import sys | 13 import sys |
| 14 import textwrap | 14 import textwrap |
| 15 | 15 |
| 16 from pprint import pformat | 16 from pprint import pformat |
| 17 | 17 |
| 18 import git_common as git | 18 import git_common as git |
| 19 | 19 |
| 20 | 20 |
| 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.get_config(STARTING_BRANCH_KEY) |
| 31 if not return_branch: | 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|.""" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 % (return_branch, root_branch) | 242 % (return_branch, root_branch) |
| 243 ) | 243 ) |
| 244 git.run('checkout', root_branch) | 244 git.run('checkout', root_branch) |
| 245 git.set_config(STARTING_BRANCH_KEY, '') | 245 git.set_config(STARTING_BRANCH_KEY, '') |
| 246 | 246 |
| 247 return retcode | 247 return retcode |
| 248 | 248 |
| 249 | 249 |
| 250 if __name__ == '__main__': # pragma: no cover | 250 if __name__ == '__main__': # pragma: no cover |
| 251 sys.exit(main(sys.argv[1:])) | 251 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |