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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 content) | 311 content) |
312 break | 312 break |
313 if response.status < 500 or try_count >= 2: | 313 if response.status < 500 or try_count >= 2: |
314 raise httplib2.HttpLib2Error(content) | 314 raise httplib2.HttpLib2Error(content) |
315 | 315 |
316 # status >= 500 means transient failures. | 316 # status >= 500 means transient failures. |
317 logging.debug('Transient errors when triggering tryjobs. Will retry.') | 317 logging.debug('Transient errors when triggering tryjobs. Will retry.') |
318 time.sleep(0.5 + 1.5*try_count) | 318 time.sleep(0.5 + 1.5*try_count) |
319 | 319 |
320 print '\n'.join(print_text) | 320 print '\n'.join(print_text) |
321 | 321 |
322 | 322 |
323 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards): | 323 def MatchSvnGlob(url, base_url, glob_spec, allow_wildcards): |
324 """Return the corresponding git ref if |base_url| together with |glob_spec| | 324 """Return the corresponding git ref if |base_url| together with |glob_spec| |
325 matches the full |url|. | 325 matches the full |url|. |
326 | 326 |
327 If |allow_wildcards| is true, |glob_spec| can contain wildcards (see below). | 327 If |allow_wildcards| is true, |glob_spec| can contain wildcards (see below). |
328 """ | 328 """ |
329 fetch_suburl, as_ref = glob_spec.split(':') | 329 fetch_suburl, as_ref = glob_spec.split(':') |
330 if allow_wildcards: | 330 if allow_wildcards: |
331 glob_match = re.match('(.+/)?(\*|{[^/]*})(/.+)?', fetch_suburl) | 331 glob_match = re.match('(.+/)?(\*|{[^/]*})(/.+)?', fetch_suburl) |
(...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 remote_url = (cl.GetRemoteUrl() + '@' | 2064 remote_url = (cl.GetRemoteUrl() + '@' |
2065 + cl.GetUpstreamBranch().split('/')[-1]) | 2065 + cl.GetUpstreamBranch().split('/')[-1]) |
2066 if remote_url: | 2066 if remote_url: |
2067 upload_args.extend(['--base_url', remote_url]) | 2067 upload_args.extend(['--base_url', remote_url]) |
2068 remote, remote_branch = cl.GetRemoteBranch() | 2068 remote, remote_branch = cl.GetRemoteBranch() |
2069 target_ref = GetTargetRef(remote, remote_branch, options.target_branch, | 2069 target_ref = GetTargetRef(remote, remote_branch, options.target_branch, |
2070 settings.GetPendingRefPrefix()) | 2070 settings.GetPendingRefPrefix()) |
2071 if target_ref: | 2071 if target_ref: |
2072 upload_args.extend(['--target_ref', target_ref]) | 2072 upload_args.extend(['--target_ref', target_ref]) |
2073 | 2073 |
| 2074 # Look for dependent patchsets. See crbug/480453 for more details. |
| 2075 remote, upstream_branch = cl.FetchUpstreamTuple(cl.GetBranch()) |
| 2076 upstream_branch = ShortBranchName(upstream_branch) |
| 2077 if remote is '.': |
| 2078 # A local branch is being tracked. |
| 2079 local_branch = ShortBranchName(upstream_branch) |
| 2080 auth_config = auth.extract_auth_config_from_options(options) |
| 2081 branch_cl = Changelist(branchref=local_branch, auth_config=auth_config) |
| 2082 branch_cl_issue_url = branch_cl.GetIssueURL() |
| 2083 branch_cl_status = branch_cl.GetStatus() |
| 2084 # Check if the local branch's CL should be marked as a dependency. |
| 2085 if branch_cl_status in ('unsent', 'waiting', 'reply', 'lgtm'): |
| 2086 branch_cl_issue = branch_cl.GetIssue() |
| 2087 branch_cl_patchset = branch_cl.GetPatchset() |
| 2088 upload_args.extend( |
| 2089 ['--depends_on_patchset', '%s:%s' % ( |
| 2090 branch_cl_issue, branch_cl_patchset)]) |
| 2091 print |
| 2092 print ('The current branch (%s) is tracking a local branch (%s) with ' |
| 2093 'an open CL.') % (cl.GetBranch(), local_branch) |
| 2094 print 'Adding %s/#ps%s as a dependency patchset.' % ( |
| 2095 branch_cl_issue_url, branch_cl_patchset) |
| 2096 print |
| 2097 |
2074 project = settings.GetProject() | 2098 project = settings.GetProject() |
2075 if project: | 2099 if project: |
2076 upload_args.extend(['--project', project]) | 2100 upload_args.extend(['--project', project]) |
2077 | 2101 |
2078 if options.cq_dry_run: | 2102 if options.cq_dry_run: |
2079 upload_args.extend(['--cq_dry_run']) | 2103 upload_args.extend(['--cq_dry_run']) |
2080 | 2104 |
2081 try: | 2105 try: |
2082 upload_args = ['upload'] + upload_args + args | 2106 upload_args = ['upload'] + upload_args + args |
2083 logging.info('upload.RealMain(%s)', upload_args) | 2107 logging.info('upload.RealMain(%s)', upload_args) |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3343 if __name__ == '__main__': | 3367 if __name__ == '__main__': |
3344 # These affect sys.stdout so do it outside of main() to simplify mocks in | 3368 # These affect sys.stdout so do it outside of main() to simplify mocks in |
3345 # unit testing. | 3369 # unit testing. |
3346 fix_encoding.fix_encoding() | 3370 fix_encoding.fix_encoding() |
3347 colorama.init() | 3371 colorama.init() |
3348 try: | 3372 try: |
3349 sys.exit(main(sys.argv[1:])) | 3373 sys.exit(main(sys.argv[1:])) |
3350 except KeyboardInterrupt: | 3374 except KeyboardInterrupt: |
3351 sys.stderr.write('interrupted\n') | 3375 sys.stderr.write('interrupted\n') |
3352 sys.exit(1) | 3376 sys.exit(1) |
OLD | NEW |