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

Side by Side Diff: cros_mark_as_stable.py

Issue 5783001: Add support to pushing unstable changes for the chrome pfq. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Sanity check after sync Created 10 years 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 | « bin/cros_mark_chrome_as_stable_unittest.py ('k') | 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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 class EBuildStableMarker(object): 390 class EBuildStableMarker(object):
391 """Class that revs the ebuild and commits locally or pushes the change.""" 391 """Class that revs the ebuild and commits locally or pushes the change."""
392 392
393 def __init__(self, ebuild): 393 def __init__(self, ebuild):
394 assert ebuild 394 assert ebuild
395 self._ebuild = ebuild 395 self._ebuild = ebuild
396 396
397 @classmethod 397 @classmethod
398 def MarkAsStable(cls, unstable_ebuild_path, new_stable_ebuild_path, 398 def MarkAsStable(cls, unstable_ebuild_path, new_stable_ebuild_path,
399 commit_keyword, commit_value, redirect_file=None): 399 commit_keyword, commit_value, redirect_file=None,
400 make_stable=True):
400 """Static function that creates a revved stable ebuild. 401 """Static function that creates a revved stable ebuild.
401 402
402 This function assumes you have already figured out the name of the new 403 This function assumes you have already figured out the name of the new
403 stable ebuild path and then creates that file from the given unstable 404 stable ebuild path and then creates that file from the given unstable
404 ebuild and marks it as stable. If the commit_value is set, it also 405 ebuild and marks it as stable. If the commit_value is set, it also
405 set the commit_keyword=commit_value pair in the ebuild. 406 set the commit_keyword=commit_value pair in the ebuild.
406 407
407 Args: 408 Args:
408 unstable_ebuild_path: The path to the unstable ebuild. 409 unstable_ebuild_path: The path to the unstable ebuild.
409 new_stable_ebuild_path: The path you want to use for the new stable 410 new_stable_ebuild_path: The path you want to use for the new stable
410 ebuild. 411 ebuild.
411 commit_keyword: Optional keyword to set in the ebuild to mark it as 412 commit_keyword: Optional keyword to set in the ebuild to mark it as
412 stable. 413 stable.
413 commit_value: Value to set the above keyword to. 414 commit_value: Value to set the above keyword to.
414 redirect_file: Optionally redirect output of new ebuild somewhere else. 415 redirect_file: Optionally redirect output of new ebuild somewhere else.
416 make_stable: Actually make the ebuild stable.
415 """ 417 """
416 shutil.copyfile(unstable_ebuild_path, new_stable_ebuild_path) 418 shutil.copyfile(unstable_ebuild_path, new_stable_ebuild_path)
417 for line in fileinput.input(new_stable_ebuild_path, inplace=1): 419 for line in fileinput.input(new_stable_ebuild_path, inplace=1):
418 # Has to be done here to get changes to sys.stdout from fileinput.input. 420 # Has to be done here to get changes to sys.stdout from fileinput.input.
419 if not redirect_file: 421 if not redirect_file:
420 redirect_file = sys.stdout 422 redirect_file = sys.stdout
421 if line.startswith('KEYWORDS'): 423 if line.startswith('KEYWORDS'):
422 # Actually mark this file as stable by removing ~'s. 424 # Actually mark this file as stable by removing ~'s.
423 redirect_file.write(line.replace('~', '')) 425 if make_stable:
426 redirect_file.write(line.replace('~', ''))
427 else:
428 redirect_file.write(line)
424 elif line.startswith('EAPI'): 429 elif line.startswith('EAPI'):
425 # Always add new commit_id after EAPI definition. 430 # Always add new commit_id after EAPI definition.
426 redirect_file.write(line) 431 redirect_file.write(line)
427 if commit_keyword and commit_value: 432 if commit_keyword and commit_value:
428 redirect_file.write('%s="%s"\n' % (commit_keyword, commit_value)) 433 redirect_file.write('%s="%s"\n' % (commit_keyword, commit_value))
429 elif not line.startswith(commit_keyword): 434 elif not line.startswith(commit_keyword):
430 # Skip old commit_keyword definition. 435 # Skip old commit_keyword definition.
431 redirect_file.write(line) 436 redirect_file.write(line)
432 fileinput.close() 437 fileinput.close()
433 438
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 if gflags.FLAGS.drop_file: 577 if gflags.FLAGS.drop_file:
573 fh = open(gflags.FLAGS.drop_file, 'w') 578 fh = open(gflags.FLAGS.drop_file, 'w')
574 fh.write(' '.join(revved_packages)) 579 fh.write(' '.join(revved_packages))
575 fh.close() 580 fh.close()
576 else: 581 else:
577 work_branch.Delete() 582 work_branch.Delete()
578 583
579 584
580 if __name__ == '__main__': 585 if __name__ == '__main__':
581 main(sys.argv) 586 main(sys.argv)
OLDNEW
« no previous file with comments | « bin/cros_mark_chrome_as_stable_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698