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 |
11 | 11 |
12 import gclient_utils | |
13 from scm import GIT | 12 from scm import GIT |
| 13 import subprocess2 |
14 import third_party.upload | 14 import third_party.upload |
15 import trychange | 15 import trychange |
16 | 16 |
17 | 17 |
18 def GetRietveldIssueNumber(): | 18 def GetRietveldIssueNumber(): |
19 try: | 19 try: |
20 return GIT.Capture( | 20 return GIT.Capture( |
21 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)]) | 21 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)]) |
22 except gclient_utils.Error: | 22 except subprocess2.CalledProcessError: |
23 return None | 23 return None |
24 | 24 |
25 | 25 |
26 def GetRietveldPatchsetNumber(): | 26 def GetRietveldPatchsetNumber(): |
27 try: | 27 try: |
28 return GIT.Capture( | 28 return GIT.Capture( |
29 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)]) | 29 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)]) |
30 except gclient_utils.Error: | 30 except subprocess2.CalledProcessError: |
31 return None | 31 return None |
32 | 32 |
33 | 33 |
34 def GetRietveldServerUrl(): | 34 def GetRietveldServerUrl(): |
35 try: | 35 try: |
36 return GIT.Capture(['config', 'rietveld.server']).strip() | 36 return GIT.Capture(['config', 'rietveld.server']).strip() |
37 except gclient_utils.Error: | 37 except subprocess2.CalledProcessError: |
38 return None | 38 return None |
39 | 39 |
40 | 40 |
41 if __name__ == '__main__': | 41 if __name__ == '__main__': |
42 args = sys.argv[1:] | 42 args = sys.argv[1:] |
43 patchset = GetRietveldPatchsetNumber() | 43 patchset = GetRietveldPatchsetNumber() |
44 if patchset: | 44 if patchset: |
45 args.extend([ | 45 args.extend([ |
46 '--issue', GetRietveldIssueNumber(), | 46 '--issue', GetRietveldIssueNumber(), |
47 '--patchset', patchset, | 47 '--patchset', patchset, |
48 ]) | 48 ]) |
49 else: | 49 else: |
50 rietveld_url = GetRietveldServerUrl() | 50 rietveld_url = GetRietveldServerUrl() |
51 if rietveld_url: | 51 if rietveld_url: |
52 args.extend(['--rietveld_url', GetRietveldServerUrl()]) | 52 args.extend(['--rietveld_url', GetRietveldServerUrl()]) |
53 # Hack around a limitation in logging. | 53 # Hack around a limitation in logging. |
54 logging.getLogger().handlers = [] | 54 logging.getLogger().handlers = [] |
55 try: | 55 try: |
56 sys.exit(trychange.TryChange( | 56 sys.exit(trychange.TryChange( |
57 args, file_list=[], swallow_exception=False, | 57 args, file_list=[], swallow_exception=False, |
58 prog='git try', | 58 prog='git try', |
59 extra_epilog='\n' | 59 extra_epilog='\n' |
60 'git try will diff against your tracked branch and will ' | 60 'git try will diff against your tracked branch and will ' |
61 'detect your rietveld\n' | 61 'detect your rietveld\n' |
62 'code review if you are using git-cl\n')) | 62 'code review if you are using git-cl\n')) |
63 except third_party.upload.ClientLoginError, e: | 63 except third_party.upload.ClientLoginError, e: |
64 print('Got an exception while trying to log in to Rietveld.') | 64 print('Got an exception while trying to log in to Rietveld.') |
65 print(str(e)) | 65 print(str(e)) |
OLD | NEW |