| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 | 10 import breakpad |
| 11 | 11 |
| 12 import gclient_utils |
| 12 from scm import GIT | 13 from scm import GIT |
| 13 import trychange | 14 import trychange |
| 14 | 15 |
| 15 | 16 |
| 16 def GetRietveldIssueNumber(): | 17 def GetRietveldIssueNumber(): |
| 17 return GIT.Capture( | 18 try: |
| 18 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)], | 19 return GIT.Capture( |
| 19 error_ok=True)[0] | 20 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch(None)]) |
| 21 except gclient_utils.Error: |
| 22 return None |
| 20 | 23 |
| 21 | 24 |
| 22 def GetRietveldPatchsetNumber(): | 25 def GetRietveldPatchsetNumber(): |
| 23 return GIT.Capture( | 26 try: |
| 24 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)], | 27 return GIT.Capture( |
| 25 error_ok=True)[0] | 28 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch(None)]) |
| 29 except gclient_utils.Error: |
| 30 return None |
| 26 | 31 |
| 27 | 32 |
| 28 def GetRietveldServerUrl(): | 33 def GetRietveldServerUrl(): |
| 29 return GIT.Capture( | 34 try: |
| 30 ['config', 'rietveld.server'], error_ok=True)[0].strip() | 35 return GIT.Capture(['config', 'rietveld.server']).strip() |
| 36 except gclient_utils.Error: |
| 37 return None |
| 31 | 38 |
| 32 | 39 |
| 33 if __name__ == '__main__': | 40 if __name__ == '__main__': |
| 34 args = sys.argv[:] | 41 args = sys.argv[:] |
| 35 patchset = GetRietveldPatchsetNumber() | 42 patchset = GetRietveldPatchsetNumber() |
| 36 if patchset: | 43 if patchset: |
| 37 args.extend([ | 44 args.extend([ |
| 38 '--issue', GetRietveldIssueNumber(), | 45 '--issue', GetRietveldIssueNumber(), |
| 39 '--patchset', patchset, | 46 '--patchset', patchset, |
| 40 ]) | 47 ]) |
| 41 else: | 48 else: |
| 42 rietveld_url = GetRietveldServerUrl() | 49 rietveld_url = GetRietveldServerUrl() |
| 43 if rietveld_url: | 50 if rietveld_url: |
| 44 args.extend(['--rietveld_url', GetRietveldServerUrl()]) | 51 args.extend(['--rietveld_url', GetRietveldServerUrl()]) |
| 45 # Hack around a limitation in logging. | 52 # Hack around a limitation in logging. |
| 46 logging.getLogger().handlers = [] | 53 logging.getLogger().handlers = [] |
| 47 sys.exit(trychange.TryChange( | 54 sys.exit(trychange.TryChange( |
| 48 args, file_list=[], swallow_exception=False, | 55 args, file_list=[], swallow_exception=False, |
| 49 prog='git-try', | 56 prog='git-try', |
| 50 extra_epilog='\n' | 57 extra_epilog='\n' |
| 51 'git-try will diff against your tracked branch and will ' | 58 'git-try will diff against your tracked branch and will ' |
| 52 'detect your rietveld\n' | 59 'detect your rietveld\n' |
| 53 'code review if you are using git-cl\n')) | 60 'code review if you are using git-cl\n')) |
| OLD | NEW |