| 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 19 matching lines...) Expand all Loading... |
| 30 WHITE = colorama.Fore.WHITE | 30 WHITE = colorama.Fore.WHITE |
| 31 | 31 |
| 32 BLUEBAK = colorama.Back.BLUE | 32 BLUEBAK = colorama.Back.BLUE |
| 33 | 33 |
| 34 BRIGHT = colorama.Style.BRIGHT | 34 BRIGHT = colorama.Style.BRIGHT |
| 35 RESET = colorama.Fore.RESET + colorama.Back.RESET + colorama.Style.RESET_ALL | 35 RESET = colorama.Fore.RESET + colorama.Back.RESET + colorama.Style.RESET_ALL |
| 36 | 36 |
| 37 # Git emits combined color | 37 # Git emits combined color |
| 38 BRIGHT_RED = '\x1b[1;31m' | 38 BRIGHT_RED = '\x1b[1;31m' |
| 39 | 39 |
| 40 def main(): | 40 def main(argv): |
| 41 map_extra = config_list('depot_tools.map_extra') | 41 map_extra = config_list('depot_tools.map_extra') |
| 42 fmt = '%C(red bold)%h%x09%Creset%C(green)%d%Creset %C(yellow)%ad%Creset ~ %s' | 42 fmt = '%C(red bold)%h%x09%Creset%C(green)%d%Creset %C(yellow)%ad%Creset ~ %s' |
| 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 + argv, |
| 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} | 53 merge_base_map = {b: v for b, v in merge_base_map.iteritems() if v} |
| 54 if current in all_branches: | 54 if current in all_branches: |
| 55 all_branches.remove(current) | 55 all_branches.remove(current) |
| 56 all_tags = set(tags()) | 56 all_tags = set(tags()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 sys.stdout.write(line) | 103 sys.stdout.write(line) |
| 104 except (IOError, KeyboardInterrupt): | 104 except (IOError, KeyboardInterrupt): |
| 105 pass | 105 pass |
| 106 finally: | 106 finally: |
| 107 sys.stderr.close() | 107 sys.stderr.close() |
| 108 sys.stdout.close() | 108 sys.stdout.close() |
| 109 return 0 | 109 return 0 |
| 110 | 110 |
| 111 | 111 |
| 112 if __name__ == '__main__': | 112 if __name__ == '__main__': |
| 113 sys.exit(main()) | 113 try: |
| 114 | 114 sys.exit(main(sys.argv[1:])) |
| 115 except KeyboardInterrupt: |
| 116 print 'interrupted' |
| 117 sys.exit(1) |
| OLD | NEW |