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
4 # found in the LICENSE file.
5 """Wrapper for trychange.py for git checkout."""
10 import breakpad # pylint: disable=W0611
14 import third_party.upload
19 def GetRietveldIssueNumber():
22 ['config', 'branch.%s.rietveldissue' % GIT.GetBranch('.')],
24 except subprocess2.CalledProcessError:
28 def GetRietveldPatchsetNumber():
31 ['config', 'branch.%s.rietveldpatchset' % GIT.GetBranch('.')],
33 except subprocess2.CalledProcessError:
37 def GetRietveldServerUrl():
39 return GIT.Capture(['config', 'rietveld.server'], '.').strip()
40 except subprocess2.CalledProcessError:
44 if __name__ == '__main__':
46 patchset = GetRietveldPatchsetNumber()
49 '--issue', GetRietveldIssueNumber(),
50 '--patchset', patchset,
53 rietveld_url = GetRietveldServerUrl()
55 args.extend(['--rietveld_url', GetRietveldServerUrl()])
57 cl = git_cl.Changelist()
58 change = cl.GetChange(cl.GetUpstreamBranch(), None)
59 # Hack around a limitation in logging.
60 logging.getLogger().handlers = []
61 sys.exit(trychange.TryChange(
62 args, change, swallow_exception=False,
65 'git try will diff against your tracked branch and will '
66 'detect your rietveld\n'
67 'code review if you are using git-cl\n'))
68 except third_party.upload.ClientLoginError, e:
69 print('Got an exception while trying to log in to Rietveld.')