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

Side by Side Diff: git_map.py

Issue 224933003: Fix colorization bug where BRIGHT+WHITE would wrap around to the next line. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 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 | « no previous file | no next file » | 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """ 6 """
7 Provides an augmented `git log --graph` view. In particular, it also annotates 7 Provides an augmented `git log --graph` view. In particular, it also annotates
8 commits with branches + tags that point to them. Items are colorized as follows: 8 commits with branches + tags that point to them. Items are colorized as follows:
9 * Cyan - Currently checked out branch 9 * Cyan - Currently checked out branch
10 * Green - Local branch 10 * Green - Local branch
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 commit = line[line.find(BRIGHT_RED)+len(BRIGHT_RED):line.find('\t')] 59 commit = line[line.find(BRIGHT_RED)+len(BRIGHT_RED):line.find('\t')]
60 base_for_branches = set() 60 base_for_branches = set()
61 for branch, sha in merge_base_map.iteritems(): 61 for branch, sha in merge_base_map.iteritems():
62 if sha.startswith(commit): 62 if sha.startswith(commit):
63 base_for_branches.add(branch) 63 base_for_branches.add(branch)
64 if base_for_branches: 64 if base_for_branches:
65 newline = '\r\n' if line.endswith('\r\n') else '\n' 65 newline = '\r\n' if line.endswith('\r\n') else '\n'
66 line = line.rstrip(newline) 66 line = line.rstrip(newline)
67 line += ''.join( 67 line += ''.join(
68 (BRIGHT, WHITE, ' <(%s)' % (', '.join(base_for_branches)), 68 (BRIGHT, WHITE, ' <(%s)' % (', '.join(base_for_branches)),
69 newline)) 69 RESET, newline))
70 for b in base_for_branches: 70 for b in base_for_branches:
71 del merge_base_map[b] 71 del merge_base_map[b]
72 72
73 start = line.find(GREEN+' (') 73 start = line.find(GREEN+' (')
74 end = line.find(')', start) 74 end = line.find(')', start)
75 if start != -1 and end != -1: 75 if start != -1 and end != -1:
76 start += len(GREEN) + 2 76 start += len(GREEN) + 2
77 branch_list = line[start:end].split(', ') 77 branch_list = line[start:end].split(', ')
78 branches_str = '' 78 branches_str = ''
79 if branch_list: 79 if branch_list:
(...skipping 24 matching lines...) Expand all
104 pass 104 pass
105 finally: 105 finally:
106 sys.stderr.close() 106 sys.stderr.close()
107 sys.stdout.close() 107 sys.stdout.close()
108 return 0 108 return 0
109 109
110 110
111 if __name__ == '__main__': 111 if __name__ == '__main__':
112 sys.exit(main()) 112 sys.exit(main())
113 113
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698