| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 import datetime | 10 import datetime |
| (...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 git_command = ['push'] | 1545 git_command = ['push'] |
| 1546 if receive_options: | 1546 if receive_options: |
| 1547 git_command.append('--receive-pack=git receive-pack %s' % | 1547 git_command.append('--receive-pack=git receive-pack %s' % |
| 1548 ' '.join(receive_options)) | 1548 ' '.join(receive_options)) |
| 1549 git_command += [remote, 'HEAD:refs/for/' + branch] | 1549 git_command += [remote, 'HEAD:refs/for/' + branch] |
| 1550 RunGit(git_command) | 1550 RunGit(git_command) |
| 1551 # TODO(ukai): parse Change-Id: and set issue number? | 1551 # TODO(ukai): parse Change-Id: and set issue number? |
| 1552 return 0 | 1552 return 0 |
| 1553 | 1553 |
| 1554 | 1554 |
| 1555 def RietveldUpload(options, args, cl): | 1555 def RietveldUpload(options, args, cl, change): |
| 1556 """upload the patch to rietveld.""" | 1556 """upload the patch to rietveld.""" |
| 1557 upload_args = ['--assume_yes'] # Don't ask about untracked files. | 1557 upload_args = ['--assume_yes'] # Don't ask about untracked files. |
| 1558 upload_args.extend(['--server', cl.GetRietveldServer()]) | 1558 upload_args.extend(['--server', cl.GetRietveldServer()]) |
| 1559 if options.emulate_svn_auto_props: | 1559 if options.emulate_svn_auto_props: |
| 1560 upload_args.append('--emulate_svn_auto_props') | 1560 upload_args.append('--emulate_svn_auto_props') |
| 1561 | 1561 |
| 1562 change_desc = None | 1562 change_desc = None |
| 1563 | 1563 |
| 1564 if options.email is not None: | 1564 if options.email is not None: |
| 1565 upload_args.extend(['--email', options.email]) | 1565 upload_args.extend(['--email', options.email]) |
| 1566 | 1566 |
| 1567 if cl.GetIssue(): | 1567 if cl.GetIssue(): |
| 1568 if options.title: | 1568 if options.title: |
| 1569 upload_args.extend(['--title', options.title]) | 1569 upload_args.extend(['--title', options.title]) |
| 1570 if options.message: | 1570 if options.message: |
| 1571 upload_args.extend(['--message', options.message]) | 1571 upload_args.extend(['--message', options.message]) |
| 1572 upload_args.extend(['--issue', str(cl.GetIssue())]) | 1572 upload_args.extend(['--issue', str(cl.GetIssue())]) |
| 1573 print ("This branch is associated with issue %s. " | 1573 print ("This branch is associated with issue %s. " |
| 1574 "Adding patch to that issue." % cl.GetIssue()) | 1574 "Adding patch to that issue." % cl.GetIssue()) |
| 1575 else: | 1575 else: |
| 1576 if options.title: | 1576 if options.title: |
| 1577 upload_args.extend(['--title', options.title]) | 1577 upload_args.extend(['--title', options.title]) |
| 1578 message = options.title or options.message or CreateDescriptionFromLog(args) | 1578 message = options.title or options.message or CreateDescriptionFromLog(args) |
| 1579 change_desc = ChangeDescription(message) | 1579 change_desc = ChangeDescription(message) |
| 1580 if options.reviewers: | 1580 if options.reviewers: |
| 1581 change_desc.update_reviewers(options.reviewers) | 1581 change_desc.update_reviewers(options.reviewers) |
| 1582 if options.auto_bots: |
| 1583 masters = presubmit_support.DoGetTryMasters( |
| 1584 change, |
| 1585 change.LocalPaths(), |
| 1586 settings.GetRoot(), |
| 1587 None, |
| 1588 None, |
| 1589 options.verbose, |
| 1590 sys.stdout) |
| 1591 |
| 1592 if masters: |
| 1593 change_description = change_desc.description + '\nCQ_TRYBOTS=' |
| 1594 lst = [] |
| 1595 for master, mapping in masters.iteritems(): |
| 1596 lst.append(master + ':' + ','.join(mapping.keys())) |
| 1597 change_desc.set_description(change_description + ';'.join(lst)) |
| 1582 if not options.force: | 1598 if not options.force: |
| 1583 change_desc.prompt() | 1599 change_desc.prompt() |
| 1584 | 1600 |
| 1585 if not change_desc.description: | 1601 if not change_desc.description: |
| 1586 print "Description is empty; aborting." | 1602 print "Description is empty; aborting." |
| 1587 return 1 | 1603 return 1 |
| 1588 | 1604 |
| 1589 upload_args.extend(['--message', change_desc.description]) | 1605 upload_args.extend(['--message', change_desc.description]) |
| 1590 if change_desc.get_reviewers(): | 1606 if change_desc.get_reviewers(): |
| 1591 upload_args.append('--reviewers=' + ','.join(change_desc.get_reviewers())) | 1607 upload_args.append('--reviewers=' + ','.join(change_desc.get_reviewers())) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1702 help="Emulate Subversion's auto properties feature.") | 1718 help="Emulate Subversion's auto properties feature.") |
| 1703 parser.add_option('-c', '--use-commit-queue', action='store_true', | 1719 parser.add_option('-c', '--use-commit-queue', action='store_true', |
| 1704 help='tell the commit queue to commit this patchset') | 1720 help='tell the commit queue to commit this patchset') |
| 1705 parser.add_option('--private', action='store_true', | 1721 parser.add_option('--private', action='store_true', |
| 1706 help='set the review private (rietveld only)') | 1722 help='set the review private (rietveld only)') |
| 1707 parser.add_option('--target_branch', | 1723 parser.add_option('--target_branch', |
| 1708 help='When uploading to gerrit, remote branch to ' | 1724 help='When uploading to gerrit, remote branch to ' |
| 1709 'use for CL. Default: master') | 1725 'use for CL. Default: master') |
| 1710 parser.add_option('--email', default=None, | 1726 parser.add_option('--email', default=None, |
| 1711 help='email address to use to connect to Rietveld') | 1727 help='email address to use to connect to Rietveld') |
| 1728 parser.add_option('--auto-bots', default=False, action='store_true', |
| 1729 help='Autogenerate which trybots to use for this CL') |
| 1712 | 1730 |
| 1713 add_git_similarity(parser) | 1731 add_git_similarity(parser) |
| 1714 (options, args) = parser.parse_args(args) | 1732 (options, args) = parser.parse_args(args) |
| 1715 | 1733 |
| 1716 if options.target_branch and not settings.GetIsGerrit(): | 1734 if options.target_branch and not settings.GetIsGerrit(): |
| 1717 parser.error('Use --target_branch for non gerrit repository.') | 1735 parser.error('Use --target_branch for non gerrit repository.') |
| 1718 | 1736 |
| 1719 if is_dirty_git_tree('upload'): | 1737 if is_dirty_git_tree('upload'): |
| 1720 return 1 | 1738 return 1 |
| 1721 | 1739 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1761 'the most recent patchset on the server is #%d.' | 1779 'the most recent patchset on the server is #%d.' |
| 1762 % (local_patchset, latest_patchset)) | 1780 % (local_patchset, latest_patchset)) |
| 1763 print ('Uploading will still work, but if you\'ve uploaded to this issue ' | 1781 print ('Uploading will still work, but if you\'ve uploaded to this issue ' |
| 1764 'from another machine or branch the patch you\'re uploading now ' | 1782 'from another machine or branch the patch you\'re uploading now ' |
| 1765 'might not include those changes.') | 1783 'might not include those changes.') |
| 1766 ask_for_data('About to upload; enter to confirm.') | 1784 ask_for_data('About to upload; enter to confirm.') |
| 1767 | 1785 |
| 1768 print_stats(options.similarity, options.find_copies, args) | 1786 print_stats(options.similarity, options.find_copies, args) |
| 1769 if settings.GetIsGerrit(): | 1787 if settings.GetIsGerrit(): |
| 1770 return GerritUpload(options, args, cl) | 1788 return GerritUpload(options, args, cl) |
| 1771 ret = RietveldUpload(options, args, cl) | 1789 ret = RietveldUpload(options, args, cl, change) |
| 1772 if not ret: | 1790 if not ret: |
| 1773 git_set_branch_value('last-upload-hash', | 1791 git_set_branch_value('last-upload-hash', |
| 1774 RunGit(['rev-parse', 'HEAD']).strip()) | 1792 RunGit(['rev-parse', 'HEAD']).strip()) |
| 1775 | 1793 |
| 1776 return ret | 1794 return ret |
| 1777 | 1795 |
| 1778 | 1796 |
| 1779 def IsSubmoduleMergeCommit(ref): | 1797 def IsSubmoduleMergeCommit(ref): |
| 1780 # When submodules are added to the repo, we expect there to be a single | 1798 # When submodules are added to the repo, we expect there to be a single |
| 1781 # non-git-svn merge commit at remote HEAD with a signature comment. | 1799 # non-git-svn merge commit at remote HEAD with a signature comment. |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2632 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2650 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2633 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2651 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2634 | 2652 |
| 2635 | 2653 |
| 2636 if __name__ == '__main__': | 2654 if __name__ == '__main__': |
| 2637 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2655 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2638 # unit testing. | 2656 # unit testing. |
| 2639 fix_encoding.fix_encoding() | 2657 fix_encoding.fix_encoding() |
| 2640 colorama.init() | 2658 colorama.init() |
| 2641 sys.exit(main(sys.argv[1:])) | 2659 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |