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

Side by Side Diff: git_cl.py

Issue 1166673002: Fix bug in git cl patch using raw patch URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Parsing Rietveld server for raw patch instead 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 | 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 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 2381 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 2713
2714 if type(issue_arg) is int or issue_arg.isdigit(): 2714 if type(issue_arg) is int or issue_arg.isdigit():
2715 # Input is an issue id. Figure out the URL. 2715 # Input is an issue id. Figure out the URL.
2716 issue = int(issue_arg) 2716 issue = int(issue_arg)
2717 cl = Changelist(issue=issue, auth_config=auth_config) 2717 cl = Changelist(issue=issue, auth_config=auth_config)
2718 patchset = cl.GetMostRecentPatchset() 2718 patchset = cl.GetMostRecentPatchset()
2719 patch_data = cl.GetPatchSetDiff(issue, patchset) 2719 patch_data = cl.GetPatchSetDiff(issue, patchset)
2720 else: 2720 else:
2721 # Assume it's a URL to the patch. Default to https. 2721 # Assume it's a URL to the patch. Default to https.
2722 issue_url = gclient_utils.UpgradeToHttps(issue_arg) 2722 issue_url = gclient_utils.UpgradeToHttps(issue_arg)
2723 match = re.match(r'.*?/issue(\d+)_(\d+).diff', issue_url) 2723 match = re.match(r'(.*?)/download/issue(\d+)_(\d+).diff', issue_url)
2724 if not match: 2724 if not match:
2725 DieWithError('Must pass an issue ID or full URL for ' 2725 DieWithError('Must pass an issue ID or full URL for '
2726 '\'Download raw patch set\'') 2726 '\'Download raw patch set\'')
2727 issue = int(match.group(1)) 2727 issue = int(match.group(2))
2728 patchset = int(match.group(2)) 2728 cl = Changelist(issue=issue, auth_config=auth_config)
2729 cl.rietveld_server = match.group(1)
2730 patchset = int(match.group(3))
2729 patch_data = urllib2.urlopen(issue_arg).read() 2731 patch_data = urllib2.urlopen(issue_arg).read()
2730 2732
2731 # Switch up to the top-level directory, if necessary, in preparation for 2733 # Switch up to the top-level directory, if necessary, in preparation for
2732 # applying the patch. 2734 # applying the patch.
2733 top = settings.GetRelativeRoot() 2735 top = settings.GetRelativeRoot()
2734 if top: 2736 if top:
2735 os.chdir(top) 2737 os.chdir(top)
2736 2738
2737 # Git patches have a/ at the beginning of source paths. We strip that out 2739 # Git patches have a/ at the beginning of source paths. We strip that out
2738 # with a sed script rather than the -p flag to patch so we can feed either 2740 # with a sed script rather than the -p flag to patch so we can feed either
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
3343 if __name__ == '__main__': 3345 if __name__ == '__main__':
3344 # These affect sys.stdout so do it outside of main() to simplify mocks in 3346 # These affect sys.stdout so do it outside of main() to simplify mocks in
3345 # unit testing. 3347 # unit testing.
3346 fix_encoding.fix_encoding() 3348 fix_encoding.fix_encoding()
3347 colorama.init() 3349 colorama.init()
3348 try: 3350 try:
3349 sys.exit(main(sys.argv[1:])) 3351 sys.exit(main(sys.argv[1:]))
3350 except KeyboardInterrupt: 3352 except KeyboardInterrupt:
3351 sys.stderr.write('interrupted\n') 3353 sys.stderr.write('interrupted\n')
3352 sys.exit(1) 3354 sys.exit(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