OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 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 |
| 4 # found in the LICENSE file. |
| 5 |
2 """ | 6 """ |
3 Provides a short mapping of all the branches in your local repo, organized by | 7 Provides a short mapping of all the branches in your local repo, organized by |
4 their upstream ('tracking branch') layout. Example: | 8 their upstream ('tracking branch') layout. Example: |
5 | 9 |
6 origin/master | 10 origin/master |
7 cool_feature | 11 cool_feature |
8 dependent_feature | 12 dependent_feature |
9 other_dependent_feature | 13 other_dependent_feature |
10 other_feature | 14 other_feature |
11 | 15 |
(...skipping 26 matching lines...) Expand all Loading... |
38 elif branch_hash == cur_hash: | 42 elif branch_hash == cur_hash: |
39 color = Fore.CYAN | 43 color = Fore.CYAN |
40 else: | 44 else: |
41 color = Fore.GREEN | 45 color = Fore.GREEN |
42 | 46 |
43 if branch_hash == cur_hash: | 47 if branch_hash == cur_hash: |
44 color += Style.BRIGHT | 48 color += Style.BRIGHT |
45 else: | 49 else: |
46 color += Style.NORMAL | 50 color += Style.NORMAL |
47 | 51 |
48 print color + " "*depth + branch + (" *" if branch == cur else "") | 52 suffix = '' |
| 53 if cur == 'HEAD': |
| 54 if branch_hash == cur_hash: |
| 55 suffix = ' *' |
| 56 elif branch == cur: |
| 57 suffix = ' *' |
| 58 |
| 59 print color + " "*depth + branch + suffix |
49 for child in par_map.pop(branch, ()): | 60 for child in par_map.pop(branch, ()): |
50 print_branch(cur, cur_hash, child, branch_hashes, par_map, branch_map, | 61 print_branch(cur, cur_hash, child, branch_hashes, par_map, branch_map, |
51 depth=depth+1) | 62 depth=depth+1) |
52 | 63 |
53 | 64 |
54 def main(argv): | 65 def main(argv): |
55 colorama.init() | 66 colorama.init() |
56 assert len(argv) == 1, "No arguments expected" | 67 assert len(argv) == 1, "No arguments expected" |
57 branch_map = {} | 68 branch_map = {} |
58 par_map = collections.defaultdict(list) | 69 par_map = collections.defaultdict(list) |
(...skipping 13 matching lines...) Expand all Loading... |
72 if parent not in par_hashes: | 83 if parent not in par_hashes: |
73 par_hashes[parent] = hash_one(parent) | 84 par_hashes[parent] = hash_one(parent) |
74 print_branch(current, current_hash, parent, par_hashes, par_map, | 85 print_branch(current, current_hash, parent, par_hashes, par_map, |
75 branch_map) | 86 branch_map) |
76 break | 87 break |
77 | 88 |
78 | 89 |
79 if __name__ == '__main__': | 90 if __name__ == '__main__': |
80 sys.exit(main(sys.argv)) | 91 sys.exit(main(sys.argv)) |
81 | 92 |
OLD | NEW |