| 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 |
| 11 * Red - Remote branches | 11 * Red - Remote branches |
| 12 * Magenta - Tags | 12 * Magenta - Tags |
| 13 * White - Merge Base Markers | 13 * White - Merge Base Markers |
| 14 * Blue background - The currently checked out commit | 14 * Blue background - The currently checked out commit |
| 15 """ | 15 """ |
| 16 | 16 |
| 17 import sys | 17 import sys |
| 18 | 18 |
| 19 import subprocess2 | 19 import subprocess2 |
| 20 | 20 |
| 21 from git_common import current_branch, branches, tags, config_list, GIT_EXE | 21 from git_common import current_branch, branches, tags, get_config_list, GIT_EXE |
| 22 from git_common import get_or_create_merge_base, root | 22 from git_common import get_or_create_merge_base, root |
| 23 | 23 |
| 24 from third_party import colorama | 24 from third_party import colorama |
| 25 | 25 |
| 26 CYAN = colorama.Fore.CYAN | 26 CYAN = colorama.Fore.CYAN |
| 27 GREEN = colorama.Fore.GREEN | 27 GREEN = colorama.Fore.GREEN |
| 28 MAGENTA = colorama.Fore.MAGENTA | 28 MAGENTA = colorama.Fore.MAGENTA |
| 29 RED = colorama.Fore.RED | 29 RED = colorama.Fore.RED |
| 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(argv): | 40 def main(argv): |
| 41 map_extra = config_list('depot_tools.map_extra') | 41 map_extra = get_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 + argv, | 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()) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 try: | 113 try: |
| 114 sys.exit(main(sys.argv[1:])) | 114 sys.exit(main(sys.argv[1:])) |
| 115 except KeyboardInterrupt: | 115 except KeyboardInterrupt: |
| 116 sys.stderr.write('interrupted\n') | 116 sys.stderr.write('interrupted\n') |
| 117 sys.exit(1) | 117 sys.exit(1) |
| OLD | NEW |