| 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 """Client-side script to send a try job to the try server. It communicates to | 6 """Client-side script to send a try job to the try server. It communicates to |
| 7 the try server by either writting to a svn/git repository or by directly | 7 the try server by either writting to a svn/git repository or by directly |
| 8 connecting to the server by HTTP. | 8 connecting to the server by HTTP. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 except gerrit_util.GerritError, e: | 772 except gerrit_util.GerritError, e: |
| 773 if e.http_status == 400: | 773 if e.http_status == 400: |
| 774 raise Error(e.reason) | 774 raise Error(e.reason) |
| 775 else: | 775 else: |
| 776 raise | 776 raise |
| 777 | 777 |
| 778 head_sha = scm.GIT.Capture(['log', '-1', '--format=%H'], cwd=os.getcwd()) | 778 head_sha = scm.GIT.Capture(['log', '-1', '--format=%H'], cwd=os.getcwd()) |
| 779 | 779 |
| 780 change_id = GetChangeId(head_sha) | 780 change_id = GetChangeId(head_sha) |
| 781 | 781 |
| 782 # Check that the uploaded revision matches the local one. | 782 try: |
| 783 changes = gerrit_util.GetChangeCurrentRevision(gerrit_host, change_id) | 783 # Check that the uploaded revision matches the local one. |
| 784 changes = gerrit_util.GetChangeCurrentRevision(gerrit_host, change_id) |
| 785 except gerrit_util.GerritAuthenticationError, e: |
| 786 raise NoTryServerAccess(e.message) |
| 787 |
| 784 assert len(changes) <= 1, 'Multiple changes with id %s' % change_id | 788 assert len(changes) <= 1, 'Multiple changes with id %s' % change_id |
| 785 if not changes: | 789 if not changes: |
| 786 raise Error('A change %s was not found on the server. Was it uploaded?' % | 790 raise Error('A change %s was not found on the server. Was it uploaded?' % |
| 787 change_id) | 791 change_id) |
| 788 logging.debug('Found Gerrit change: %s' % changes[0]) | 792 logging.debug('Found Gerrit change: %s' % changes[0]) |
| 789 if changes[0]['current_revision'] != head_sha: | 793 if changes[0]['current_revision'] != head_sha: |
| 790 raise Error('Please upload your latest local changes to Gerrit.') | 794 raise Error('Please upload your latest local changes to Gerrit.') |
| 791 | 795 |
| 792 # Post a try job. | 796 # Post a try job. |
| 793 message = FormatMessage() | 797 message = FormatMessage() |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 return 1 | 1252 return 1 |
| 1249 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 1253 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
| 1250 print >> sys.stderr, e | 1254 print >> sys.stderr, e |
| 1251 return 1 | 1255 return 1 |
| 1252 return 0 | 1256 return 0 |
| 1253 | 1257 |
| 1254 | 1258 |
| 1255 if __name__ == "__main__": | 1259 if __name__ == "__main__": |
| 1256 fix_encoding.fix_encoding() | 1260 fix_encoding.fix_encoding() |
| 1257 sys.exit(TryChange(None, None, False)) | 1261 sys.exit(TryChange(None, None, False)) |
| OLD | NEW |