| 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 Enhances `git log --graph` view with information on commit branches + tags that |
| 8 commits with branches + tags that point to them. Items are colorized as follows: | 8 point to them. Items are colorized as follows: |
| 9 |
| 9 * Cyan - Currently checked out branch | 10 * Cyan - Currently checked out branch |
| 10 * Green - Local branch | 11 * Green - Local branch |
| 11 * Red - Remote branches | 12 * Red - Remote branches |
| 12 * Magenta - Tags | 13 * Magenta - Tags |
| 13 * White - Merge Base Markers | 14 * White - Merge Base Markers |
| 14 * Blue background - The currently checked out commit | 15 * Blue background - The currently checked out commit |
| 15 """ | 16 """ |
| 16 | 17 |
| 17 import sys | 18 import sys |
| 18 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 30 WHITE = colorama.Fore.WHITE | 31 WHITE = colorama.Fore.WHITE |
| 31 | 32 |
| 32 BLUEBAK = colorama.Back.BLUE | 33 BLUEBAK = colorama.Back.BLUE |
| 33 | 34 |
| 34 BRIGHT = colorama.Style.BRIGHT | 35 BRIGHT = colorama.Style.BRIGHT |
| 35 RESET = colorama.Fore.RESET + colorama.Back.RESET + colorama.Style.RESET_ALL | 36 RESET = colorama.Fore.RESET + colorama.Back.RESET + colorama.Style.RESET_ALL |
| 36 | 37 |
| 37 # Git emits combined color | 38 # Git emits combined color |
| 38 BRIGHT_RED = '\x1b[1;31m' | 39 BRIGHT_RED = '\x1b[1;31m' |
| 39 | 40 |
| 41 |
| 42 def print_help(): |
| 43 names = { |
| 44 'Cyan': CYAN, |
| 45 'Green': GREEN, |
| 46 'Magenta': MAGENTA, |
| 47 'Red': RED, |
| 48 'White': WHITE, |
| 49 'Blue background': BLUEBAK, |
| 50 } |
| 51 msg = "usage: git map [-h] [<args>]\n" |
| 52 |
| 53 for line in __doc__.splitlines(): |
| 54 for key in names.keys(): |
| 55 if key in line: |
| 56 msg += line.replace('* ', '* ' + names[key])+RESET+'\n' |
| 57 break |
| 58 else: |
| 59 msg += line + '\n' |
| 60 sys.stdout.write(msg) |
| 61 |
| 62 |
| 40 def main(argv): | 63 def main(argv): |
| 64 if '-h' in argv: |
| 65 print_help() |
| 66 return 0 |
| 67 |
| 41 map_extra = get_config_list('depot_tools.map_extra') | 68 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' | 69 fmt = '%C(red bold)%h%x09%Creset%C(green)%d%Creset %C(yellow)%ad%Creset ~ %s' |
| 43 log_proc = subprocess2.Popen( | 70 log_proc = subprocess2.Popen( |
| 44 [GIT_EXE, 'log', '--graph', '--branches', '--tags', root(), | 71 [GIT_EXE, 'log', '--graph', '--branches', '--tags', root(), |
| 45 '--color=always', '--date=short', ('--pretty=format:' + fmt) | 72 '--color=always', '--date=short', ('--pretty=format:' + fmt) |
| 46 ] + map_extra + argv, | 73 ] + map_extra + argv, |
| 47 stdout=subprocess2.PIPE, | 74 stdout=subprocess2.PIPE, |
| 48 shell=False) | 75 shell=False) |
| 49 | 76 |
| 50 current = current_branch() | 77 current = current_branch() |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 sys.stdout.close() | 135 sys.stdout.close() |
| 109 return 0 | 136 return 0 |
| 110 | 137 |
| 111 | 138 |
| 112 if __name__ == '__main__': | 139 if __name__ == '__main__': |
| 113 try: | 140 try: |
| 114 sys.exit(main(sys.argv[1:])) | 141 sys.exit(main(sys.argv[1:])) |
| 115 except KeyboardInterrupt: | 142 except KeyboardInterrupt: |
| 116 sys.stderr.write('interrupted\n') | 143 sys.stderr.write('interrupted\n') |
| 117 sys.exit(1) | 144 sys.exit(1) |
| OLD | NEW |