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 2019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2030 # And then swap back to the original branch and clean up. | 2030 # And then swap back to the original branch and clean up. |
2031 RunGit(['checkout', '-q', cl.GetBranch()]) | 2031 RunGit(['checkout', '-q', cl.GetBranch()]) |
2032 RunGit(['branch', '-D', MERGE_BRANCH]) | 2032 RunGit(['branch', '-D', MERGE_BRANCH]) |
2033 if base_has_submodules: | 2033 if base_has_submodules: |
2034 RunGit(['branch', '-D', CHERRY_PICK_BRANCH]) | 2034 RunGit(['branch', '-D', CHERRY_PICK_BRANCH]) |
2035 | 2035 |
2036 if not revision: | 2036 if not revision: |
2037 print 'Failed to push. If this persists, please file a bug.' | 2037 print 'Failed to push. If this persists, please file a bug.' |
2038 return 1 | 2038 return 1 |
2039 | 2039 |
2040 killed = False | |
2040 if pushed_to_pending: | 2041 if pushed_to_pending: |
2041 try: | 2042 try: |
2042 revision = WaitForRealCommit(remote, revision, base_branch, branch) | 2043 revision = WaitForRealCommit(remote, revision, base_branch, branch) |
2043 # We set pushed_to_pending to False, since it made it all the way to the | 2044 # We set pushed_to_pending to False, since it made it all the way to the |
2044 # real ref. | 2045 # real ref. |
2045 pushed_to_pending = False | 2046 pushed_to_pending = False |
2046 except KeyboardInterrupt: | 2047 except KeyboardInterrupt: |
2048 killed = True | |
2047 pass | 2049 pass |
Michael Moss
2014/09/05 17:23:25
nit: remove pass
| |
2048 | 2050 |
2049 if cl.GetIssue(): | 2051 if cl.GetIssue(): |
2050 to_pending = ' to pending queue' if pushed_to_pending else '' | 2052 to_pending = ' to pending queue' if pushed_to_pending else '' |
2051 viewvc_url = settings.GetViewVCUrl() | 2053 viewvc_url = settings.GetViewVCUrl() |
2052 if not to_pending: | 2054 if not to_pending: |
2053 if viewvc_url and revision: | 2055 if viewvc_url and revision: |
2054 change_desc.append_footer( | 2056 change_desc.append_footer( |
2055 'Committed: %s%s' % (viewvc_url, revision)) | 2057 'Committed: %s%s' % (viewvc_url, revision)) |
2056 elif revision: | 2058 elif revision: |
2057 change_desc.append_footer('Committed: %s' % (revision,)) | 2059 change_desc.append_footer('Committed: %s' % (revision,)) |
(...skipping 16 matching lines...) Expand all Loading... | |
2074 _, branch = cl.FetchUpstreamTuple(cl.GetBranch()) | 2076 _, branch = cl.FetchUpstreamTuple(cl.GetBranch()) |
2075 print 'The commit is in the pending queue (%s).' % pending_ref | 2077 print 'The commit is in the pending queue (%s).' % pending_ref |
2076 print ( | 2078 print ( |
2077 'It will show up on %s in ~1 min, once it gets Cr-Commit-Position ' | 2079 'It will show up on %s in ~1 min, once it gets Cr-Commit-Position ' |
2078 'footer.' % branch) | 2080 'footer.' % branch) |
2079 | 2081 |
2080 hook = POSTUPSTREAM_HOOK_PATTERN % cmd | 2082 hook = POSTUPSTREAM_HOOK_PATTERN % cmd |
2081 if os.path.isfile(hook): | 2083 if os.path.isfile(hook): |
2082 RunCommand([hook, merge_base], error_ok=True) | 2084 RunCommand([hook, merge_base], error_ok=True) |
2083 | 2085 |
2084 return 0 | 2086 return 1 if killed else 0 |
2085 | 2087 |
2086 | 2088 |
2087 def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref): | 2089 def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref): |
2088 print | 2090 print |
2089 print 'Waiting for commit to be landed on %s...' % real_ref | 2091 print 'Waiting for commit to be landed on %s...' % real_ref |
2090 print '(If you are impatient, you may Ctrl-C once without harm)' | 2092 print '(If you are impatient, you may Ctrl-C once without harm)' |
2091 target_tree = RunGit(['rev-parse', '%s:' % pushed_commit]).strip() | 2093 target_tree = RunGit(['rev-parse', '%s:' % pushed_commit]).strip() |
2092 current_rev = RunGit(['rev-parse', local_base_ref]).strip() | 2094 current_rev = RunGit(['rev-parse', local_base_ref]).strip() |
2093 | 2095 |
2094 loop = 0 | 2096 loop = 0 |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2797 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2799 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2798 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2800 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2799 | 2801 |
2800 | 2802 |
2801 if __name__ == '__main__': | 2803 if __name__ == '__main__': |
2802 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2804 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2803 # unit testing. | 2805 # unit testing. |
2804 fix_encoding.fix_encoding() | 2806 fix_encoding.fix_encoding() |
2805 colorama.init() | 2807 colorama.init() |
2806 sys.exit(main(sys.argv[1:])) | 2808 sys.exit(main(sys.argv[1:])) |
OLD | NEW |