Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Side by Side Diff: git_cl.py

Issue 1851283002: Fix coloring madness in depot_tools. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Improve logic a bit Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gclient.py ('k') | git_common.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 and Gerrit.""" 8 """A git-command for integrating reviews on Rietveld and Gerrit."""
9 9
10 from distutils.version import LooseVersion 10 from distutils.version import LooseVersion
(...skipping 27 matching lines...) Expand all
38 pass 38 pass
39 39
40 from third_party import colorama 40 from third_party import colorama
41 from third_party import httplib2 41 from third_party import httplib2
42 from third_party import upload 42 from third_party import upload
43 import auth 43 import auth
44 from luci_hacks import trigger_luci_job as luci_trigger 44 from luci_hacks import trigger_luci_job as luci_trigger
45 import clang_format 45 import clang_format
46 import commit_queue 46 import commit_queue
47 import dart_format 47 import dart_format
48 import setup_color
48 import fix_encoding 49 import fix_encoding
49 import gclient_utils 50 import gclient_utils
50 import gerrit_util 51 import gerrit_util
51 import git_cache 52 import git_cache
52 import git_common 53 import git_common
53 import git_footers 54 import git_footers
54 import owners 55 import owners
55 import owners_finder 56 import owners_finder
56 import presubmit_support 57 import presubmit_support
57 import rietveld 58 import rietveld
(...skipping 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after
2474 2475
2475 branch_statuses = {} 2476 branch_statuses = {}
2476 alignment = max(5, max(len(ShortBranchName(b)) for b in branches)) 2477 alignment = max(5, max(len(ShortBranchName(b)) for b in branches))
2477 for branch in sorted(branches): 2478 for branch in sorted(branches):
2478 while branch not in branch_statuses: 2479 while branch not in branch_statuses:
2479 b, i, status = output.next() 2480 b, i, status = output.next()
2480 branch_statuses[b] = (i, status) 2481 branch_statuses[b] = (i, status)
2481 issue_url, status = branch_statuses.pop(branch) 2482 issue_url, status = branch_statuses.pop(branch)
2482 color = color_for_status(status) 2483 color = color_for_status(status)
2483 reset = Fore.RESET 2484 reset = Fore.RESET
2484 if not sys.stdout.isatty(): 2485 if not setup_color.IS_TTY:
2485 color = '' 2486 color = ''
2486 reset = '' 2487 reset = ''
2487 status_str = '(%s)' % status if status else '' 2488 status_str = '(%s)' % status if status else ''
2488 print ' %*s : %s%s %s%s' % ( 2489 print ' %*s : %s%s %s%s' % (
2489 alignment, ShortBranchName(branch), color, issue_url, status_str, 2490 alignment, ShortBranchName(branch), color, issue_url, status_str,
2490 reset) 2491 reset)
2491 2492
2492 cl = Changelist(auth_config=auth_config) 2493 cl = Changelist(auth_config=auth_config)
2493 print 2494 print
2494 print 'Current branch:', 2495 print 'Current branch:',
(...skipping 1679 matching lines...) Expand 10 before | Expand all | Expand 10 after
4174 return 0 4175 return 0
4175 4176
4176 4177
4177 def CMDtry_results(parser, args): 4178 def CMDtry_results(parser, args):
4178 group = optparse.OptionGroup(parser, "Try job results options") 4179 group = optparse.OptionGroup(parser, "Try job results options")
4179 group.add_option( 4180 group.add_option(
4180 "-p", "--patchset", type=int, help="patchset number if not current.") 4181 "-p", "--patchset", type=int, help="patchset number if not current.")
4181 group.add_option( 4182 group.add_option(
4182 "--print-master", action='store_true', help="print master name as well.") 4183 "--print-master", action='store_true', help="print master name as well.")
4183 group.add_option( 4184 group.add_option(
4184 "--color", action='store_true', default=sys.stdout.isatty(), 4185 "--color", action='store_true', default=setup_color.IS_TTY,
4185 help="force color output, useful when piping output.") 4186 help="force color output, useful when piping output.")
4186 group.add_option( 4187 group.add_option(
4187 "--buildbucket-host", default='cr-buildbucket.appspot.com', 4188 "--buildbucket-host", default='cr-buildbucket.appspot.com',
4188 help="Host of buildbucket. The default host is %default.") 4189 help="Host of buildbucket. The default host is %default.")
4189 parser.add_option_group(group) 4190 parser.add_option_group(group)
4190 auth.add_auth_options(parser) 4191 auth.add_auth_options(parser)
4191 options, args = parser.parse_args(args) 4192 options, args = parser.parse_args(args)
4192 if args: 4193 if args:
4193 parser.error('Unrecognized args: %s' % ' '.join(args)) 4194 parser.error('Unrecognized args: %s' % ' '.join(args))
4194 4195
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
4608 DieWithError( 4609 DieWithError(
4609 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 4610 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
4610 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 4611 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
4611 return 0 4612 return 0
4612 4613
4613 4614
4614 if __name__ == '__main__': 4615 if __name__ == '__main__':
4615 # These affect sys.stdout so do it outside of main() to simplify mocks in 4616 # These affect sys.stdout so do it outside of main() to simplify mocks in
4616 # unit testing. 4617 # unit testing.
4617 fix_encoding.fix_encoding() 4618 fix_encoding.fix_encoding()
4618 colorama.init(wrap="TERM" not in os.environ) 4619 setup_color.init()
4619 try: 4620 try:
4620 sys.exit(main(sys.argv[1:])) 4621 sys.exit(main(sys.argv[1:]))
4621 except KeyboardInterrupt: 4622 except KeyboardInterrupt:
4622 sys.stderr.write('interrupted\n') 4623 sys.stderr.write('interrupted\n')
4623 sys.exit(1) 4624 sys.exit(1)
OLDNEW
« no previous file with comments | « gclient.py ('k') | git_common.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698