| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 """Client-side script to send a try job to the try server. It communicates to | 5 """Client-side script to send a try job to the try server. It communicates to |
| 6 the try server by either writting to a svn repository or by directly connecting | 6 the try server by either writting to a svn repository or by directly connecting |
| 7 to the server by HTTP. | 7 to the server by HTTP. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 import datetime | 10 import datetime |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 562 |
| 563 # Convert options.diff into the content of the diff. | 563 # Convert options.diff into the content of the diff. |
| 564 if options.url: | 564 if options.url: |
| 565 if options.files: | 565 if options.files: |
| 566 parser.error('You cannot specify files and --url at the same time.') | 566 parser.error('You cannot specify files and --url at the same time.') |
| 567 options.diff = urllib.urlopen(options.url).read() | 567 options.diff = urllib.urlopen(options.url).read() |
| 568 elif options.diff: | 568 elif options.diff: |
| 569 if options.files: | 569 if options.files: |
| 570 parser.error('You cannot specify files and --diff at the same time.') | 570 parser.error('You cannot specify files and --diff at the same time.') |
| 571 options.diff = gclient_utils.FileRead(options.diff, 'rb') | 571 options.diff = gclient_utils.FileRead(options.diff, 'rb') |
| 572 elif options.issue: | 572 elif options.issue and options.patchset is None: |
| 573 # Retrieve the patch from rietveld when the diff is not specified. | 573 # Retrieve the patch from rietveld when the diff is not specified. |
| 574 try: | 574 try: |
| 575 import simplejson | 575 import simplejson |
| 576 except ImportError: | 576 except ImportError: |
| 577 parser.error('simplejson library is missing, please install.') | 577 parser.error('simplejson library is missing, please install.') |
| 578 api_url = 'http://%s/api/%d' % (options.rietveld_url, options.issue) | 578 api_url = 'http://%s/api/%d' % (options.rietveld_url, options.issue) |
| 579 contents = simplejson.loads(urllib.urlopen(api_url).read()) | 579 contents = simplejson.loads(urllib.urlopen(api_url).read()) |
| 580 diff_url = ('http://%s/download/issue%d_%d.diff' % | 580 diff_url = ('http://%s/download/issue%d_%d.diff' % |
| 581 (options.rietveld_url, options.issue, contents['patchsets'][-1])) | 581 (options.rietveld_url, options.issue, contents['patchsets'][-1])) |
| 582 diff = GetMungedDiff('', urllib.urlopen(diff_url).readlines()) | 582 diff = GetMungedDiff('', urllib.urlopen(diff_url).readlines()) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 except (InvalidScript, NoTryServerAccess), e: | 642 except (InvalidScript, NoTryServerAccess), e: |
| 643 if swallow_exception: | 643 if swallow_exception: |
| 644 return 1 | 644 return 1 |
| 645 print e | 645 print e |
| 646 return 1 | 646 return 1 |
| 647 return 0 | 647 return 0 |
| 648 | 648 |
| 649 | 649 |
| 650 if __name__ == "__main__": | 650 if __name__ == "__main__": |
| 651 sys.exit(TryChange(None, [], False)) | 651 sys.exit(TryChange(None, [], False)) |
| OLD | NEW |