OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |