OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 """Wrapper for trychange.py for git checkout.""" | 5 """Wrapper for trychange.py for git checkout.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import sys | 8 import sys |
9 | 9 |
10 import breakpad # pylint: disable=W0611 | 10 import breakpad # pylint: disable=W0611 |
(...skipping 23 matching lines...) Expand all Loading... |
34 return None | 34 return None |
35 | 35 |
36 | 36 |
37 def GetRietveldServerUrl(): | 37 def GetRietveldServerUrl(): |
38 try: | 38 try: |
39 return GIT.Capture(['config', 'rietveld.server'], '.').strip() | 39 return GIT.Capture(['config', 'rietveld.server'], '.').strip() |
40 except subprocess2.CalledProcessError: | 40 except subprocess2.CalledProcessError: |
41 return None | 41 return None |
42 | 42 |
43 | 43 |
44 if __name__ == '__main__': | 44 def main(args): |
45 args = sys.argv[1:] | |
46 patchset = GetRietveldPatchsetNumber() | 45 patchset = GetRietveldPatchsetNumber() |
47 if patchset: | 46 if patchset: |
48 args.extend([ | 47 args.extend([ |
49 '--issue', GetRietveldIssueNumber(), | 48 '--issue', GetRietveldIssueNumber(), |
50 '--patchset', patchset, | 49 '--patchset', patchset, |
51 ]) | 50 ]) |
52 else: | 51 else: |
53 rietveld_url = GetRietveldServerUrl() | 52 rietveld_url = GetRietveldServerUrl() |
54 if rietveld_url: | 53 if rietveld_url: |
55 args.extend(['--rietveld_url', GetRietveldServerUrl()]) | 54 args.extend(['--rietveld_url', GetRietveldServerUrl()]) |
56 try: | 55 try: |
57 cl = git_cl.Changelist() | 56 cl = git_cl.Changelist() |
58 change = cl.GetChange(cl.GetUpstreamBranch(), None) | 57 change = cl.GetChange(cl.GetUpstreamBranch(), None) |
59 # Hack around a limitation in logging. | 58 # Hack around a limitation in logging. |
60 logging.getLogger().handlers = [] | 59 logging.getLogger().handlers = [] |
61 sys.exit(trychange.TryChange( | 60 sys.exit(trychange.TryChange( |
62 args, change, swallow_exception=False, | 61 args, change, swallow_exception=False, |
63 prog='git try', | 62 prog='git try', |
64 extra_epilog='\n' | 63 extra_epilog='\n' |
65 'git try will diff against your tracked branch and will ' | 64 'git try will diff against your tracked branch and will ' |
66 'detect your rietveld\n' | 65 'detect your rietveld\n' |
67 'code review if you are using git-cl\n')) | 66 'code review if you are using git-cl\n')) |
68 except third_party.upload.ClientLoginError, e: | 67 except third_party.upload.ClientLoginError, e: |
69 print('Got an exception while trying to log in to Rietveld.') | 68 print('Got an exception while trying to log in to Rietveld.') |
70 print(str(e)) | 69 print(str(e)) |
| 70 return 0 |
| 71 |
| 72 |
| 73 if __name__ == '__main__': |
| 74 try: |
| 75 sys.exit(main(sys.argv[1:])) |
| 76 except KeyboardInterrupt: |
| 77 sys.stderr.write('interrupted\n') |
| 78 sys.exit(1) |
OLD | NEW |