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 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 # Cherry-pick the change on top of pending ref and then push it. | 2108 # Cherry-pick the change on top of pending ref and then push it. |
2109 assert branch.startswith('refs/'), branch | 2109 assert branch.startswith('refs/'), branch |
2110 assert pending_prefix[-1] == '/', pending_prefix | 2110 assert pending_prefix[-1] == '/', pending_prefix |
2111 pending_ref = pending_prefix + branch[len('refs/'):] | 2111 pending_ref = pending_prefix + branch[len('refs/'):] |
2112 retcode, output = PushToGitPending(remote, pending_ref, branch) | 2112 retcode, output = PushToGitPending(remote, pending_ref, branch) |
2113 pushed_to_pending = (retcode == 0) | 2113 pushed_to_pending = (retcode == 0) |
2114 if retcode == 0: | 2114 if retcode == 0: |
2115 revision = RunGit(['rev-parse', 'HEAD']).strip() | 2115 revision = RunGit(['rev-parse', 'HEAD']).strip() |
2116 else: | 2116 else: |
2117 # dcommit the merge branch. | 2117 # dcommit the merge branch. |
2118 cmd = [ | 2118 cmd_args = [ |
2119 'svn', 'dcommit', | 2119 'svn', 'dcommit', |
2120 '-C%s' % options.similarity, | 2120 '-C%s' % options.similarity, |
2121 '--no-rebase', '--rmdir', | 2121 '--no-rebase', '--rmdir', |
2122 ] | 2122 ] |
2123 if settings.GetForceHttpsCommitUrl(): | 2123 if settings.GetForceHttpsCommitUrl(): |
2124 # Allow forcing https commit URLs for some projects that don't allow | 2124 # Allow forcing https commit URLs for some projects that don't allow |
2125 # committing to http URLs (like Google Code). | 2125 # committing to http URLs (like Google Code). |
2126 remote_url = cl.GetGitSvnRemoteUrl() | 2126 remote_url = cl.GetGitSvnRemoteUrl() |
2127 if urlparse.urlparse(remote_url).scheme == 'http': | 2127 if urlparse.urlparse(remote_url).scheme == 'http': |
2128 remote_url = remote_url.replace('http://', 'https://') | 2128 remote_url = remote_url.replace('http://', 'https://') |
2129 cmd.append('--commit-url=%s' % remote_url) | 2129 cmd_args.append('--commit-url=%s' % remote_url) |
2130 _, output = RunGitWithCode(cmd) | 2130 _, output = RunGitWithCode(cmd_args) |
2131 if 'Committed r' in output: | 2131 if 'Committed r' in output: |
2132 revision = re.match( | 2132 revision = re.match( |
2133 '.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) | 2133 '.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) |
2134 logging.debug(output) | 2134 logging.debug(output) |
2135 finally: | 2135 finally: |
2136 # And then swap back to the original branch and clean up. | 2136 # And then swap back to the original branch and clean up. |
2137 RunGit(['checkout', '-q', cl.GetBranch()]) | 2137 RunGit(['checkout', '-q', cl.GetBranch()]) |
2138 RunGit(['branch', '-D', MERGE_BRANCH]) | 2138 RunGit(['branch', '-D', MERGE_BRANCH]) |
2139 if base_has_submodules: | 2139 if base_has_submodules: |
2140 RunGit(['branch', '-D', CHERRY_PICK_BRANCH]) | 2140 RunGit(['branch', '-D', CHERRY_PICK_BRANCH]) |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2916 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2916 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2917 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2917 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2918 | 2918 |
2919 | 2919 |
2920 if __name__ == '__main__': | 2920 if __name__ == '__main__': |
2921 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2921 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2922 # unit testing. | 2922 # unit testing. |
2923 fix_encoding.fix_encoding() | 2923 fix_encoding.fix_encoding() |
2924 colorama.init() | 2924 colorama.init() |
2925 sys.exit(main(sys.argv[1:])) | 2925 sys.exit(main(sys.argv[1:])) |
OLD | NEW |