Chromium Code Reviews| Index: git_map_branches.py |
| diff --git a/git_map_branches.py b/git_map_branches.py |
| index 350fed37a15551bbb5f54791dfb6f6df32921f52..c3ac69e2c73f09f45bebcea526b53f203f3c9ac4 100755 |
| --- a/git_map_branches.py |
| +++ b/git_map_branches.py |
| @@ -27,6 +27,7 @@ Branches are colorized as follows: |
| import argparse |
| import collections |
| import sys |
| +import subprocess2 |
| from third_party import colorama |
| from third_party.colorama import Fore, Style |
| @@ -126,7 +127,7 @@ class BranchMapper(object): |
| continue |
| parent = branch_info.upstream |
| - if parent and not self.__branches_info[parent]: |
| + if not self.__branches_info[parent]: |
| branch_upstream = upstream(branch) |
| # If git can't find the upstream, mark the upstream as gone. |
| if branch_upstream: |
| @@ -156,6 +157,8 @@ class BranchMapper(object): |
| def __color_for_branch(self, branch, branch_hash): |
| if branch.startswith('origin'): |
| color = Fore.RED |
| + elif branch.startswith('branch-heads'): |
| + color = Fore.BLUE |
|
iannucci
2014/09/23 00:42:01
could you regenerate the manpage to show this, too
calamity
2014/09/23 03:28:01
Done.
|
| elif self.__is_invalid_parent(branch) or branch in self.__tag_set: |
| color = Fore.MAGENTA |
| elif self.__current_hash.startswith(branch_hash): |
| @@ -163,7 +166,7 @@ class BranchMapper(object): |
| else: |
| color = Fore.GREEN |
| - if self.__current_hash.startswith(branch_hash): |
| + if branch_hash and self.__current_hash.startswith(branch_hash): |
| color += Style.BRIGHT |
| else: |
| color += Style.NORMAL |
| @@ -177,7 +180,10 @@ class BranchMapper(object): |
| if branch_info: |
| branch_hash = branch_info.hash |
| else: |
| - branch_hash = hash_one(branch, short=True) |
| + try: |
| + branch_hash = hash_one(branch, short=True) |
| + except subprocess2.CalledProcessError: |
| + branch_hash = None |
| line = OutputLine() |
| @@ -233,7 +239,8 @@ class BranchMapper(object): |
| if self.verbosity >= 2: |
| import git_cl # avoid heavy import cost unless we need it |
| none_text = '' if self.__is_invalid_parent(branch) else 'None' |
| - url = git_cl.Changelist(branchref=branch).GetIssueURL() |
| + url = git_cl.Changelist( |
| + branchref=branch_hash).GetIssueURL() if branch_hash else None |
| line.append(url or none_text, color=Fore.BLUE if url else Fore.WHITE) |
| self.output.append(line) |