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 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 # Try to rebase the branch_squash_attempt branch to see if it's empty. | 141 # Try to rebase the branch_squash_attempt branch to see if it's empty. |
142 squash_ret = git.rebase(parent, start_hash, squash_branch, abort=True) | 142 squash_ret = git.rebase(parent, start_hash, squash_branch, abort=True) |
143 empty_rebase = git.hash_one(squash_branch) == git.hash_one(parent) | 143 empty_rebase = git.hash_one(squash_branch) == git.hash_one(parent) |
144 git.run('checkout', branch) | 144 git.run('checkout', branch) |
145 git.run('branch', '-D', squash_branch) | 145 git.run('branch', '-D', squash_branch) |
146 if squash_ret.success and empty_rebase: | 146 if squash_ret.success and empty_rebase: |
147 print 'Success!' | 147 print 'Success!' |
148 git.squash_current_branch(merge_base=start_hash) | 148 git.squash_current_branch(merge_base=start_hash) |
149 git.rebase(parent, start_hash, branch) | 149 git.rebase(parent, start_hash, branch) |
150 else: | 150 else: |
| 151 print "Failed!" |
| 152 print |
| 153 |
151 # rebase and leave in mid-rebase state. | 154 # rebase and leave in mid-rebase state. |
152 # This second rebase attempt should always fail in the same | 155 # This second rebase attempt should always fail in the same |
153 # way that the first one does. If it magically succeeds then | 156 # way that the first one does. If it magically succeeds then |
154 # something very strange has happened. | 157 # something very strange has happened. |
155 second_rebase_ret = git.rebase(parent, start_hash, branch) | 158 second_rebase_ret = git.rebase(parent, start_hash, branch) |
156 assert(not second_rebase_ret.success) | 159 if second_rebase_ret.success: # pragma: no cover |
157 print "Failed!" | 160 print "Second rebase succeeded unexpectedly!" |
158 print | 161 print "Please see: http://crbug.com/425696" |
159 print "Here's what git-rebase (squashed) had to say:" | 162 print "First rebased failed with:" |
160 print | 163 print rebase_ret.stderr |
161 print squash_ret.stdout | 164 else: |
162 print squash_ret.stderr | 165 print "Here's what git-rebase (squashed) had to say:" |
163 print textwrap.dedent( | 166 print |
164 """\ | 167 print squash_ret.stdout |
165 Squashing failed. You probably have a real merge conflict. | 168 print squash_ret.stderr |
| 169 print textwrap.dedent( |
| 170 """\ |
| 171 Squashing failed. You probably have a real merge conflict. |
166 | 172 |
167 Your working copy is in mid-rebase. Either: | 173 Your working copy is in mid-rebase. Either: |
168 * completely resolve like a normal git-rebase; OR | 174 * completely resolve like a normal git-rebase; OR |
169 * abort the rebase and mark this branch as dormant: | 175 * abort the rebase and mark this branch as dormant: |
170 git config branch.%s.dormant true | 176 git config branch.%s.dormant true |
171 | 177 |
172 And then run `git rebase-update` again to resume. | 178 And then run `git rebase-update` again to resume. |
173 """ % branch) | 179 """ % branch) |
174 return False | 180 return False |
175 else: | 181 else: |
176 print '%s up-to-date' % branch | 182 print '%s up-to-date' % branch |
177 | 183 |
178 git.remove_merge_base(branch) | 184 git.remove_merge_base(branch) |
179 git.get_or_create_merge_base(branch) | 185 git.get_or_create_merge_base(branch) |
180 | 186 |
181 return True | 187 return True |
182 | 188 |
183 | 189 |
184 def main(args=()): | 190 def main(args=()): |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 % (return_branch, root_branch) | 264 % (return_branch, root_branch) |
259 ) | 265 ) |
260 git.run('checkout', root_branch) | 266 git.run('checkout', root_branch) |
261 git.set_config(STARTING_BRANCH_KEY, '') | 267 git.set_config(STARTING_BRANCH_KEY, '') |
262 | 268 |
263 return retcode | 269 return retcode |
264 | 270 |
265 | 271 |
266 if __name__ == '__main__': # pragma: no cover | 272 if __name__ == '__main__': # pragma: no cover |
267 sys.exit(main(sys.argv[1:])) | 273 sys.exit(main(sys.argv[1:])) |
OLD | NEW |