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

Side by Side Diff: git_cl.py

Issue 1149653002: [depot_tools] Find, upload and apply patchset dependencies (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Upload dependencies even if closed Created 5 years, 6 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
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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.
agable 2015/06/08 20:05:53 nit: crbug.com/480453
rmistry 2015/06/09 16:16:45 Done.
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_issue = branch_cl.GetIssue()
2084 branch_cl_patchset = branch_cl.GetPatchset()
2085 if branch_cl_issue_url and branch_cl_issue and branch_cl_patchset:
2086 upload_args.extend(
2087 ['--depends_on_patchset', '%s:%s' % (
2088 branch_cl_issue, branch_cl_patchset)])
2089 print
2090 print ('The current branch (%s) is tracking a local branch (%s) with '
2091 'an open CL.') % (cl.GetBranch(), local_branch)
2092 print 'Adding %s/#ps%s as a dependency patchset.' % (
2093 branch_cl_issue_url, branch_cl_patchset)
2094 print
2095
2074 project = settings.GetProject() 2096 project = settings.GetProject()
2075 if project: 2097 if project:
2076 upload_args.extend(['--project', project]) 2098 upload_args.extend(['--project', project])
2077 2099
2078 if options.cq_dry_run: 2100 if options.cq_dry_run:
2079 upload_args.extend(['--cq_dry_run']) 2101 upload_args.extend(['--cq_dry_run'])
2080 2102
2081 try: 2103 try:
2082 upload_args = ['upload'] + upload_args + args 2104 upload_args = ['upload'] + upload_args + args
2083 logging.info('upload.RealMain(%s)', upload_args) 2105 logging.info('upload.RealMain(%s)', upload_args)
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after
3343 if __name__ == '__main__': 3365 if __name__ == '__main__':
3344 # These affect sys.stdout so do it outside of main() to simplify mocks in 3366 # These affect sys.stdout so do it outside of main() to simplify mocks in
3345 # unit testing. 3367 # unit testing.
3346 fix_encoding.fix_encoding() 3368 fix_encoding.fix_encoding()
3347 colorama.init() 3369 colorama.init()
3348 try: 3370 try:
3349 sys.exit(main(sys.argv[1:])) 3371 sys.exit(main(sys.argv[1:]))
3350 except KeyboardInterrupt: 3372 except KeyboardInterrupt:
3351 sys.stderr.write('interrupted\n') 3373 sys.stderr.write('interrupted\n')
3352 sys.exit(1) 3374 sys.exit(1)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698