| 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 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| 11 import glob | 11 import glob |
| 12 import json | 12 import json |
| 13 import logging | 13 import logging |
| 14 import optparse | 14 import optparse |
| 15 import os | 15 import os |
| 16 import Queue | 16 import Queue |
| 17 import re | 17 import re |
| 18 import stat | 18 import stat |
| 19 import sys | 19 import sys |
| 20 import textwrap | 20 import textwrap |
| 21 import threading | 21 import threading |
| 22 import urllib2 | 22 import urllib2 |
| 23 import urlparse | 23 import urlparse |
| 24 import webbrowser |
| 24 | 25 |
| 25 try: | 26 try: |
| 26 import readline # pylint: disable=F0401,W0611 | 27 import readline # pylint: disable=F0401,W0611 |
| 27 except ImportError: | 28 except ImportError: |
| 28 pass | 29 pass |
| 29 | 30 |
| 30 | 31 |
| 31 from third_party import colorama | 32 from third_party import colorama |
| 32 from third_party import upload | 33 from third_party import upload |
| 33 import breakpad # pylint: disable=W0611 | 34 import breakpad # pylint: disable=W0611 |
| (...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2126 print ' %*s: %s' % (length, builder, ','.join(builders_and_tests[builder])) | 2127 print ' %*s: %s' % (length, builder, ','.join(builders_and_tests[builder])) |
| 2127 return 0 | 2128 return 0 |
| 2128 | 2129 |
| 2129 | 2130 |
| 2130 @subcommand.usage('[new upstream branch]') | 2131 @subcommand.usage('[new upstream branch]') |
| 2131 def CMDupstream(parser, args): | 2132 def CMDupstream(parser, args): |
| 2132 """Prints or sets the name of the upstream branch, if any.""" | 2133 """Prints or sets the name of the upstream branch, if any.""" |
| 2133 _, args = parser.parse_args(args) | 2134 _, args = parser.parse_args(args) |
| 2134 if len(args) > 1: | 2135 if len(args) > 1: |
| 2135 parser.error('Unrecognized args: %s' % ' '.join(args)) | 2136 parser.error('Unrecognized args: %s' % ' '.join(args)) |
| 2136 return 0 | |
| 2137 | 2137 |
| 2138 cl = Changelist() | 2138 cl = Changelist() |
| 2139 if args: | 2139 if args: |
| 2140 # One arg means set upstream branch. | 2140 # One arg means set upstream branch. |
| 2141 RunGit(['branch', '--set-upstream', cl.GetBranch(), args[0]]) | 2141 RunGit(['branch', '--set-upstream', cl.GetBranch(), args[0]]) |
| 2142 cl = Changelist() | 2142 cl = Changelist() |
| 2143 print "Upstream branch set to " + cl.GetUpstreamBranch() | 2143 print "Upstream branch set to " + cl.GetUpstreamBranch() |
| 2144 else: | 2144 else: |
| 2145 print cl.GetUpstreamBranch() | 2145 print cl.GetUpstreamBranch() |
| 2146 return 0 | 2146 return 0 |
| 2147 | 2147 |
| 2148 | 2148 |
| 2149 def CMDweb(parser, args): |
| 2150 """Opens the current CL in the web browser.""" |
| 2151 _, args = parser.parse_args(args) |
| 2152 if args: |
| 2153 parser.error('Unrecognized args: %s' % ' '.join(args)) |
| 2154 |
| 2155 issue_url = Changelist().GetIssueURL() |
| 2156 if not issue_url: |
| 2157 print >> sys.stderr, 'ERROR No issue to open' |
| 2158 return 1 |
| 2159 |
| 2160 webbrowser.open(issue_url) |
| 2161 return 0 |
| 2162 |
| 2163 |
| 2149 def CMDset_commit(parser, args): | 2164 def CMDset_commit(parser, args): |
| 2150 """Sets the commit bit to trigger the Commit Queue.""" | 2165 """Sets the commit bit to trigger the Commit Queue.""" |
| 2151 _, args = parser.parse_args(args) | 2166 _, args = parser.parse_args(args) |
| 2152 if args: | 2167 if args: |
| 2153 parser.error('Unrecognized args: %s' % ' '.join(args)) | 2168 parser.error('Unrecognized args: %s' % ' '.join(args)) |
| 2154 cl = Changelist() | 2169 cl = Changelist() |
| 2155 cl.SetFlag('commit', '1') | 2170 cl.SetFlag('commit', '1') |
| 2156 return 0 | 2171 return 0 |
| 2157 | 2172 |
| 2158 | 2173 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2347 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2333 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2348 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2334 | 2349 |
| 2335 | 2350 |
| 2336 if __name__ == '__main__': | 2351 if __name__ == '__main__': |
| 2337 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2352 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2338 # unit testing. | 2353 # unit testing. |
| 2339 fix_encoding.fix_encoding() | 2354 fix_encoding.fix_encoding() |
| 2340 colorama.init() | 2355 colorama.init() |
| 2341 sys.exit(main(sys.argv[1:])) | 2356 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |