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

Side by Side Diff: git_rebase_update.py

Issue 667793005: Handle unusual case in rebase-update where second attempt works. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 1 month 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 | « 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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:
157 print "Failed!" 160 print "Second rebase succeeded. First one failed with:"
158 print 161 print rebase_ret.stderr
iannucci 2014/10/23 00:42:07 do we want to have a blurb to report this on the b
Sam Clegg 2014/10/24 20:01:24 Done.
159 print "Here's what git-rebase (squashed) had to say:" 162 else:
160 print 163 print "Here's what git-rebase (squashed) had to say:"
161 print squash_ret.stdout 164 print
162 print squash_ret.stderr 165 print squash_ret.stdout
163 print textwrap.dedent( 166 print squash_ret.stderr
164 """\ 167 print textwrap.dedent(
165 Squashing failed. You probably have a real merge conflict. 168 """\
169 Squashing failed. You probably have a real merge conflict.
166 170
167 Your working copy is in mid-rebase. Either: 171 Your working copy is in mid-rebase. Either:
168 * completely resolve like a normal git-rebase; OR 172 * completely resolve like a normal git-rebase; OR
169 * abort the rebase and mark this branch as dormant: 173 * abort the rebase and mark this branch as dormant:
170 git config branch.%s.dormant true 174 git config branch.%s.dormant true
171 175
172 And then run `git rebase-update` again to resume. 176 And then run `git rebase-update` again to resume.
173 """ % branch) 177 """ % branch)
174 return False 178 return False
175 else: 179 else:
176 print '%s up-to-date' % branch 180 print '%s up-to-date' % branch
177 181
178 git.remove_merge_base(branch) 182 git.remove_merge_base(branch)
179 git.get_or_create_merge_base(branch) 183 git.get_or_create_merge_base(branch)
180 184
181 return True 185 return True
182 186
183 187
184 def main(args=()): 188 def main(args=()):
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 % (return_branch, root_branch) 262 % (return_branch, root_branch)
259 ) 263 )
260 git.run('checkout', root_branch) 264 git.run('checkout', root_branch)
261 git.set_config(STARTING_BRANCH_KEY, '') 265 git.set_config(STARTING_BRANCH_KEY, '')
262 266
263 return retcode 267 return retcode
264 268
265 269
266 if __name__ == '__main__': # pragma: no cover 270 if __name__ == '__main__': # pragma: no cover
267 sys.exit(main(sys.argv[1:])) 271 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