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

Side by Side Diff: git_cl.py

Issue 523113003: Fail if retcode is not zero after push (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: 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 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 retcode, output = RunGitWithCode(['svn', 'dcommit', 2022 retcode, output = RunGitWithCode(['svn', 'dcommit',
2023 '-C%s' % options.similarity, 2023 '-C%s' % options.similarity,
2024 '--no-rebase', '--rmdir']) 2024 '--no-rebase', '--rmdir'])
2025 finally: 2025 finally:
2026 # And then swap back to the original branch and clean up. 2026 # And then swap back to the original branch and clean up.
2027 RunGit(['checkout', '-q', cl.GetBranch()]) 2027 RunGit(['checkout', '-q', cl.GetBranch()])
2028 RunGit(['branch', '-D', MERGE_BRANCH]) 2028 RunGit(['branch', '-D', MERGE_BRANCH])
2029 if base_has_submodules: 2029 if base_has_submodules:
2030 RunGit(['branch', '-D', CHERRY_PICK_BRANCH]) 2030 RunGit(['branch', '-D', CHERRY_PICK_BRANCH])
2031 2031
2032 if retcode == 0 and pushed_to_pending: 2032 if retcode != 0:
2033 print 'Failed to push. If this persists, please file a bug.'
2034 return retcode
2035
2036 if pushed_to_pending:
2033 try: 2037 try:
2034 revision = WaitForRealCommit(remote, revision, base_branch, branch) 2038 revision = WaitForRealCommit(remote, revision, base_branch, branch)
2035 # We set pushed_to_pending to False, since it made it all the way to the 2039 # We set pushed_to_pending to False, since it made it all the way to the
2036 # real ref. 2040 # real ref.
2037 pushed_to_pending = False 2041 pushed_to_pending = False
2038 except KeyboardInterrupt: 2042 except KeyboardInterrupt:
2039 pass 2043 pass
2040 2044
2041 if cl.GetIssue(): 2045 if cl.GetIssue():
2042 if not revision: 2046 if not revision:
2043 if cmd == 'dcommit' and 'Committed r' in output: 2047 if cmd == 'dcommit' and 'Committed r' in output:
2044 revision = re.match( 2048 revision = re.match(
2045 '.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1) 2049 '.*?\nCommitted r(\\d+)', output, re.DOTALL).group(1)
2046 elif cmd == 'land' and retcode == 0: 2050 elif cmd == 'land':
2047 match = (re.match(r'.*?([a-f0-9]{7,})\.\.([a-f0-9]{7,})$', l) 2051 match = (re.match(r'.*?([a-f0-9]{7,})\.\.([a-f0-9]{7,})$', l)
2048 for l in output.splitlines(False)) 2052 for l in output.splitlines(False))
2049 match = filter(None, match) 2053 match = filter(None, match)
2050 if len(match) != 1: 2054 if len(match) != 1:
2051 DieWithError( 2055 DieWithError(
2052 "Couldn't parse ouput to extract the committed hash:\n%s" % output) 2056 "Couldn't parse ouput to extract the committed hash:\n%s" % output)
2053 revision = match[0].group(2) 2057 revision = match[0].group(2)
2054 else: 2058 else:
2055 return 1 2059 return 1
2056 2060
(...skipping 15 matching lines...) Expand all
2072 patch_num = len(props['patchsets']) 2076 patch_num = len(props['patchsets'])
2073 comment = "Committed patchset #%d (id:%d)%s manually as %s" % ( 2077 comment = "Committed patchset #%d (id:%d)%s manually as %s" % (
2074 patch_num, props['patchsets'][-1], to_pending, revision) 2078 patch_num, props['patchsets'][-1], to_pending, revision)
2075 if options.bypass_hooks: 2079 if options.bypass_hooks:
2076 comment += ' (tree was closed).' if GetTreeStatus() == 'closed' else '.' 2080 comment += ' (tree was closed).' if GetTreeStatus() == 'closed' else '.'
2077 else: 2081 else:
2078 comment += ' (presubmit successful).' 2082 comment += ' (presubmit successful).'
2079 cl.RpcServer().add_comment(cl.GetIssue(), comment) 2083 cl.RpcServer().add_comment(cl.GetIssue(), comment)
2080 cl.SetIssue(None) 2084 cl.SetIssue(None)
2081 2085
2082 if pushed_to_pending and retcode == 0: 2086 if pushed_to_pending:
2083 _, branch = cl.FetchUpstreamTuple(cl.GetBranch()) 2087 _, branch = cl.FetchUpstreamTuple(cl.GetBranch())
2084 print 'The commit is in the pending queue (%s).' % pending_ref 2088 print 'The commit is in the pending queue (%s).' % pending_ref
2085 print ( 2089 print (
2086 'It will show up on %s in ~1 min, once it gets Cr-Commit-Position ' 2090 'It will show up on %s in ~1 min, once it gets Cr-Commit-Position '
2087 'footer.' % branch) 2091 'footer.' % branch)
2088 2092
2089 if retcode == 0: 2093 hook = POSTUPSTREAM_HOOK_PATTERN % cmd
2090 hook = POSTUPSTREAM_HOOK_PATTERN % cmd 2094 if os.path.isfile(hook):
2091 if os.path.isfile(hook): 2095 RunCommand([hook, merge_base], error_ok=True)
2092 RunCommand([hook, merge_base], error_ok=True)
2093 2096
2094 return 0 2097 return 0
2095 2098
2096 2099
2097 def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref): 2100 def WaitForRealCommit(remote, pushed_commit, local_base_ref, real_ref):
2098 print 2101 print
2099 print 'Waiting for commit to be landed on %s...' % real_ref 2102 print 'Waiting for commit to be landed on %s...' % real_ref
2100 print '(If you are impatient, you may Ctrl-C once without harm)' 2103 print '(If you are impatient, you may Ctrl-C once without harm)'
2101 target_tree = RunGit(['rev-parse', '%s:' % pushed_commit]).strip() 2104 target_tree = RunGit(['rev-parse', '%s:' % pushed_commit]).strip()
2102 current_rev = RunGit(['rev-parse', local_base_ref]).strip() 2105 current_rev = RunGit(['rev-parse', local_base_ref]).strip()
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2810 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2808 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2811 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2809 2812
2810 2813
2811 if __name__ == '__main__': 2814 if __name__ == '__main__':
2812 # These affect sys.stdout so do it outside of main() to simplify mocks in 2815 # These affect sys.stdout so do it outside of main() to simplify mocks in
2813 # unit testing. 2816 # unit testing.
2814 fix_encoding.fix_encoding() 2817 fix_encoding.fix_encoding()
2815 colorama.init() 2818 colorama.init()
2816 sys.exit(main(sys.argv[1:])) 2819 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