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

Side by Side Diff: cros_mark_as_stable.py

Issue 5142003: Add retries to pfq push. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 10 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """This module uprevs a given package's ebuild to the next revision.""" 7 """This module uprevs a given package's ebuild to the next revision."""
8 8
9 9
10 import fileinput 10 import fileinput
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 208
209 def _PushChange(): 209 def _PushChange():
210 """Pushes changes to the git repository. 210 """Pushes changes to the git repository.
211 211
212 Pushes locals commits from calls to CommitChange to the remote git 212 Pushes locals commits from calls to CommitChange to the remote git
213 repository specified by os.pwd. 213 repository specified by os.pwd.
214 214
215 Raises: 215 Raises:
216 OSError: Error occurred while pushing. 216 OSError: Error occurred while pushing.
217 """ 217 """
218 num_retries = 5
218 219
219 # TODO(sosa) - Add logic for buildbot to check whether other slaves have 220 # TODO(sosa) - Add logic for buildbot to check whether other slaves have
220 # completed and push this change only if they have. 221 # completed and push this change only if they have.
221 222
222 # Sanity check to make sure we're on a stabilizing branch before pushing. 223 # Sanity check to make sure we're on a stabilizing branch before pushing.
223 if not _CheckOnStabilizingBranch(): 224 if not _CheckOnStabilizingBranch():
224 Info('Not on branch %s so no work found to push. Exiting' % \ 225 Info('Not on branch %s so no work found to push. Exiting' % \
225 _STABLE_BRANCH_NAME) 226 _STABLE_BRANCH_NAME)
226 return 227 return
227 228
228 description = _SimpleRunCommand('git log --format=format:%s%n%n%b ' + 229 description = _SimpleRunCommand('git log --format=format:%s%n%n%b ' +
229 gflags.FLAGS.tracking_branch + '..') 230 gflags.FLAGS.tracking_branch + '..')
230 description = 'Marking set of ebuilds as stable\n\n%s' % description 231 description = 'Marking set of ebuilds as stable\n\n%s' % description
231 merge_branch_name = 'merge_branch' 232 merge_branch_name = 'merge_branch'
232 _SimpleRunCommand('git remote update') 233 for push_try in range(num_retries + 1):
233 merge_branch = _GitBranch(merge_branch_name) 234 try:
234 merge_branch.CreateBranch() 235 _SimpleRunCommand('git remote update')
235 if not merge_branch.Exists(): 236 merge_branch = _GitBranch(merge_branch_name)
236 Die('Unable to create merge branch.') 237 merge_branch.CreateBranch()
237 _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME) 238 if not merge_branch.Exists():
238 _SimpleRunCommand('git commit -m "%s"' % description) 239 Die('Unable to create merge branch.')
239 # Ugh. There has got to be an easier way to push to a tracking branch 240 _SimpleRunCommand('git merge --squash %s' % _STABLE_BRANCH_NAME)
240 _SimpleRunCommand('git config push.default tracking') 241 _SimpleRunCommand('git commit -m "%s"' % description)
241 _SimpleRunCommand('git push') 242 # Ugh. There has got to be an easier way to push to a tracking branch
243 _SimpleRunCommand('git config push.default tracking')
244 _SimpleRunCommand('git push')
245 break
246 except:
247 if push_try < num_retries:
248 Warning('Failed to push change, performing retry (%s/%s)' % (
249 push_try + 1, num_retries))
250 else:
251 raise
242 252
243 253
244 def _SimpleRunCommand(command): 254 def _SimpleRunCommand(command):
245 """Runs a shell command and returns stdout back to caller.""" 255 """Runs a shell command and returns stdout back to caller."""
246 _Print(' + %s' % command) 256 _Print(' + %s' % command)
247 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True) 257 proc_handle = subprocess.Popen(command, stdout=subprocess.PIPE, shell=True)
248 stdout = proc_handle.communicate()[0] 258 stdout = proc_handle.communicate()[0]
249 retcode = proc_handle.wait() 259 retcode = proc_handle.wait()
250 if retcode != 0: 260 if retcode != 0:
251 _Print(stdout) 261 _Print(stdout)
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 raise 559 raise
550 560
551 if revved_packages: 561 if revved_packages:
552 _CleanStalePackages(gflags.FLAGS.board, revved_packages) 562 _CleanStalePackages(gflags.FLAGS.board, revved_packages)
553 else: 563 else:
554 work_branch.Delete() 564 work_branch.Delete()
555 565
556 566
557 if __name__ == '__main__': 567 if __name__ == '__main__':
558 main(sys.argv) 568 main(sys.argv)
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