| 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 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 # When submodules are added to the repo, we expect there to be a single | 1737 # When submodules are added to the repo, we expect there to be a single |
| 1738 # non-git-svn merge commit at remote HEAD with a signature comment. | 1738 # non-git-svn merge commit at remote HEAD with a signature comment. |
| 1739 pattern = '^SVN changes up to revision [0-9]*$' | 1739 pattern = '^SVN changes up to revision [0-9]*$' |
| 1740 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] | 1740 cmd = ['rev-list', '--merges', '--grep=%s' % pattern, '%s^!' % ref] |
| 1741 return RunGit(cmd) != '' | 1741 return RunGit(cmd) != '' |
| 1742 | 1742 |
| 1743 | 1743 |
| 1744 def SendUpstream(parser, args, cmd): | 1744 def SendUpstream(parser, args, cmd): |
| 1745 """Common code for CmdPush and CmdDCommit | 1745 """Common code for CmdPush and CmdDCommit |
| 1746 | 1746 |
| 1747 Squashed commit into a single. | 1747 Squashes branch into a single commit. |
| 1748 Updates changelog with metadata (e.g. pointer to review). | 1748 Updates changelog with metadata (e.g. pointer to review). |
| 1749 Pushes/dcommits the code upstream. | 1749 Pushes/dcommits the code upstream. |
| 1750 Updates review and closes. | 1750 Updates review and closes. |
| 1751 """ | 1751 """ |
| 1752 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', | 1752 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', |
| 1753 help='bypass upload presubmit hook') | 1753 help='bypass upload presubmit hook') |
| 1754 parser.add_option('-m', dest='message', | 1754 parser.add_option('-m', dest='message', |
| 1755 help="override review description") | 1755 help="override review description") |
| 1756 parser.add_option('-f', action='store_true', dest='force', | 1756 parser.add_option('-f', action='store_true', dest='force', |
| 1757 help="force yes to questions (don't prompt)") | 1757 help="force yes to questions (don't prompt)") |
| 1758 parser.add_option('-c', dest='contributor', | 1758 parser.add_option('-c', dest='contributor', |
| 1759 help="external contributor for patch (appended to " + | 1759 help="external contributor for patch (appended to " + |
| 1760 "description and used as author for git). Should be " + | 1760 "description and used as author for git). Should be " + |
| 1761 "formatted as 'First Last <email@example.com>'") | 1761 "formatted as 'First Last <email@example.com>'") |
| 1762 add_git_similarity(parser) | 1762 add_git_similarity(parser) |
| 1763 (options, args) = parser.parse_args(args) | 1763 (options, args) = parser.parse_args(args) |
| 1764 cl = Changelist() | 1764 cl = Changelist() |
| 1765 | 1765 |
| 1766 current = cl.GetBranch() |
| 1767 remote, upstream_branch = cl.FetchUpstreamTuple(cl.GetBranch()) |
| 1768 if not settings.GetIsGitSvn() and remote == '.': |
| 1769 print |
| 1770 print 'Attempting to push branch %r into another local branch!' % current |
| 1771 print |
| 1772 print 'Either reparent this branch on top of origin/master:' |
| 1773 print ' git reparent-branch --root' |
| 1774 print |
| 1775 print 'OR run `git rebase-update` if you think the parent branch is already' |
| 1776 print 'committed.' |
| 1777 print |
| 1778 print ' Current parent: %r' % upstream_branch |
| 1779 return 1 |
| 1780 |
| 1766 if not args or cmd == 'push': | 1781 if not args or cmd == 'push': |
| 1767 # Default to merging against our best guess of the upstream branch. | 1782 # Default to merging against our best guess of the upstream branch. |
| 1768 args = [cl.GetUpstreamBranch()] | 1783 args = [cl.GetUpstreamBranch()] |
| 1769 | 1784 |
| 1770 if options.contributor: | 1785 if options.contributor: |
| 1771 if not re.match('^.*\s<\S+@\S+>$', options.contributor): | 1786 if not re.match('^.*\s<\S+@\S+>$', options.contributor): |
| 1772 print "Please provide contibutor as 'First Last <email@example.com>'" | 1787 print "Please provide contibutor as 'First Last <email@example.com>'" |
| 1773 return 1 | 1788 return 1 |
| 1774 | 1789 |
| 1775 base_branch = args[0] | 1790 base_branch = args[0] |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2542 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2557 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2543 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2558 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2544 | 2559 |
| 2545 | 2560 |
| 2546 if __name__ == '__main__': | 2561 if __name__ == '__main__': |
| 2547 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2562 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2548 # unit testing. | 2563 # unit testing. |
| 2549 fix_encoding.fix_encoding() | 2564 fix_encoding.fix_encoding() |
| 2550 colorama.init() | 2565 colorama.init() |
| 2551 sys.exit(main(sys.argv[1:])) | 2566 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |