Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 log_proc = subprocess2.Popen( | 43 log_proc = subprocess2.Popen( |
| 44 [GIT_EXE, 'log', '--graph', '--branches', '--tags', root(), | 44 [GIT_EXE, 'log', '--graph', '--branches', '--tags', root(), |
| 45 '--color=always', '--date=short', ('--pretty=format:' + fmt) | 45 '--color=always', '--date=short', ('--pretty=format:' + fmt) |
| 46 ] + map_extra + sys.argv[1:], | 46 ] + map_extra + sys.argv[1:], |
| 47 stdout=subprocess2.PIPE, | 47 stdout=subprocess2.PIPE, |
| 48 shell=False) | 48 shell=False) |
| 49 | 49 |
| 50 current = current_branch() | 50 current = current_branch() |
| 51 all_branches = set(branches()) | 51 all_branches = set(branches()) |
| 52 merge_base_map = {b: get_or_create_merge_base(b) for b in all_branches} | 52 merge_base_map = {b: get_or_create_merge_base(b) for b in all_branches} |
| 53 merge_base_map = {b: v for b, v in merge_base_map.iteritems() if v} | |
|
iannucci
2014/05/15 22:20:17
this fixes a bug for branches which have NO upstre
| |
| 53 if current in all_branches: | 54 if current in all_branches: |
| 54 all_branches.remove(current) | 55 all_branches.remove(current) |
| 55 all_tags = set(tags()) | 56 all_tags = set(tags()) |
| 56 try: | 57 try: |
| 57 for line in log_proc.stdout.xreadlines(): | 58 for line in log_proc.stdout.xreadlines(): |
| 58 if merge_base_map: | 59 if merge_base_map: |
| 59 commit = line[line.find(BRIGHT_RED)+len(BRIGHT_RED):line.find('\t')] | 60 commit = line[line.find(BRIGHT_RED)+len(BRIGHT_RED):line.find('\t')] |
| 60 base_for_branches = set() | 61 base_for_branches = set() |
| 61 for branch, sha in merge_base_map.iteritems(): | 62 for branch, sha in merge_base_map.iteritems(): |
| 62 if sha.startswith(commit): | 63 if sha.startswith(commit): |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 pass | 105 pass |
| 105 finally: | 106 finally: |
| 106 sys.stderr.close() | 107 sys.stderr.close() |
| 107 sys.stdout.close() | 108 sys.stdout.close() |
| 108 return 0 | 109 return 0 |
| 109 | 110 |
| 110 | 111 |
| 111 if __name__ == '__main__': | 112 if __name__ == '__main__': |
| 112 sys.exit(main()) | 113 sys.exit(main()) |
| 113 | 114 |
| OLD | NEW |