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

Side by Side Diff: git_cl.py

Issue 549513002: Return 1 from git_cl land when you Ctrl-C it in the middle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: fix nit Created 6 years, 3 months 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 | « no previous file | 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/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
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:
2047 pass 2048 killed = True
2048 2049
2049 if cl.GetIssue(): 2050 if cl.GetIssue():
2050 to_pending = ' to pending queue' if pushed_to_pending else '' 2051 to_pending = ' to pending queue' if pushed_to_pending else ''
2051 viewvc_url = settings.GetViewVCUrl() 2052 viewvc_url = settings.GetViewVCUrl()
2052 if not to_pending: 2053 if not to_pending:
2053 if viewvc_url and revision: 2054 if viewvc_url and revision:
2054 change_desc.append_footer( 2055 change_desc.append_footer(
2055 'Committed: %s%s' % (viewvc_url, revision)) 2056 'Committed: %s%s' % (viewvc_url, revision))
2056 elif revision: 2057 elif revision:
2057 change_desc.append_footer('Committed: %s' % (revision,)) 2058 change_desc.append_footer('Committed: %s' % (revision,))
(...skipping 16 matching lines...) Expand all
2074 _, branch = cl.FetchUpstreamTuple(cl.GetBranch()) 2075 _, branch = cl.FetchUpstreamTuple(cl.GetBranch())
2075 print 'The commit is in the pending queue (%s).' % pending_ref 2076 print 'The commit is in the pending queue (%s).' % pending_ref
2076 print ( 2077 print (
2077 'It will show up on %s in ~1 min, once it gets Cr-Commit-Position ' 2078 'It will show up on %s in ~1 min, once it gets Cr-Commit-Position '
2078 'footer.' % branch) 2079 'footer.' % branch)
2079 2080
2080 hook = POSTUPSTREAM_HOOK_PATTERN % cmd 2081 hook = POSTUPSTREAM_HOOK_PATTERN % cmd
2081 if os.path.isfile(hook): 2082 if os.path.isfile(hook):
2082 RunCommand([hook, merge_base], error_ok=True) 2083 RunCommand([hook, merge_base], error_ok=True)
2083 2084
2084 return 0 2085 return 1 if killed else 0
2085 2086
2086 2087
2087 def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref): 2088 def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref):
2088 print 2089 print
2089 print 'Waiting for commit to be landed on %s...' % real_ref 2090 print 'Waiting for commit to be landed on %s...' % real_ref
2090 print '(If you are impatient, you may Ctrl-C once without harm)' 2091 print '(If you are impatient, you may Ctrl-C once without harm)'
2091 target_tree = RunGit(['rev-parse', '%s:' % pushed_commit]).strip() 2092 target_tree = RunGit(['rev-parse', '%s:' % pushed_commit]).strip()
2092 current_rev = RunGit(['rev-parse', local_base_ref]).strip() 2093 current_rev = RunGit(['rev-parse', local_base_ref]).strip()
2093 2094
2094 loop = 0 2095 loop = 0
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2798 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2798 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2799 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2799 2800
2800 2801
2801 if __name__ == '__main__': 2802 if __name__ == '__main__':
2802 # These affect sys.stdout so do it outside of main() to simplify mocks in 2803 # These affect sys.stdout so do it outside of main() to simplify mocks in
2803 # unit testing. 2804 # unit testing.
2804 fix_encoding.fix_encoding() 2805 fix_encoding.fix_encoding()
2805 colorama.init() 2806 colorama.init()
2806 sys.exit(main(sys.argv[1:])) 2807 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698