Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(872)

Unified Diff: git_map_branches.py

Issue 576423002: Fix map-branches issues and add coloring for 'branch-heads', (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix url bug Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | man/html/git-map-branches.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_map_branches.py
diff --git a/git_map_branches.py b/git_map_branches.py
index 350fed37a15551bbb5f54791dfb6f6df32921f52..44f13c3bd5abc010269e48d05d6d82a7374ddf65 100755
--- a/git_map_branches.py
+++ b/git_map_branches.py
@@ -19,6 +19,7 @@ Branches are colorized as follows:
* Note that multiple branches may be Cyan, if they are all on the same
commit, and you have that commit checked out.
* Green - a local branch
+ * Blue - a 'branch-heads' branch
* Magenta - a tag
* Magenta '{NO UPSTREAM}' - If you have local branches which do not track any
upstream, then you will see this.
@@ -27,6 +28,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 +128,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 +158,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
elif self.__is_invalid_parent(branch) or branch in self.__tag_set:
color = Fore.MAGENTA
elif self.__current_hash.startswith(branch_hash):
@@ -163,7 +167,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 +181,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 +240,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).GetIssueURL() if branch_hash else None
line.append(url or none_text, color=Fore.BLUE if url else Fore.WHITE)
self.output.append(line)
« no previous file with comments | « no previous file | man/html/git-map-branches.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698