mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Fix map-branches issues and add coloring for 'branch-heads',
This CL fixes some issues with map-branches: * Branches with no upstream were not being shown. * -vv from a detached HEAD would crash * GONE upstreams would crash when git cleaned up in a way that caused hash_one to fail This CL also adds a blue coloring to branches that start with 'branch-heads' for Chromium release branches. BUG=416530 Review URL: https://codereview.chromium.org/576423002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@292083 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -790,6 +790,11 @@ Remote branches are <span class="red">red</span> (usually, the root of all other
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
<em>branch-heads</em> branches are <span class="blue">blue</span>.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
<code>{NO UPSTREAM}</code> is a special placeholder in <span class="fuchsia">magenta</span>.
|
||||
</p>
|
||||
<div class="ulist"><ul>
|
||||
@@ -820,13 +825,13 @@ Branches which have this as their parent are usually misconfigured, and
|
||||
assuming that the <code>frozen_changes</code> branch was currently checked out, running
|
||||
<em>git map-branches</em> would result in an output like:</p></div>
|
||||
<div class="paragraph"><p></p></div><div class="listingblock"><div class="content"><pre><code><span style="font-weight: bold; color: #ffffff">$ git map-branches</span>
|
||||
<span style="color: #e42e16"></span><span style="color: #e42e16">origin/master
|
||||
<span style="color: #d338d3"></span><span style="color: #d338d3">{NO_UPSTREAM}
|
||||
</span><span style="color: #19c518"></span><span style="color: #19c518"> no_upstream
|
||||
</span><span style="color: #e42e16"></span><span style="color: #e42e16">origin/master
|
||||
</span><span style="color: #19c518"></span><span style="color: #19c518"> cool_feature
|
||||
</span><span style="color: #19c518"></span><span style="color: #19c518"> subfeature
|
||||
</span><span style="color: #19c518"></span><span style="color: #19c518"> fixit
|
||||
</span><span style="color: #33d6e5"></span><span style="font-weight: bold; color: #33d6e5"> frozen_branch *
|
||||
</span><span style="font-weight: bold; color: #d338d3"></span><span style="color: #d338d3">{NO UPSTREAM}
|
||||
</span><span style="color: #19c518"></span><span style="color: #19c518"> no_upstream</span>
|
||||
</span><span style="color: #33d6e5"></span><span style="font-weight: bold; color: #33d6e5"> frozen_branch *</span>
|
||||
</code></pre></div></div><p><div class="paragraph"></p></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -860,7 +865,7 @@ from <a href="https://chromium.googlesource.com/chromium/tools/depot_tools.git">
|
||||
<div id="footnotes"><hr /></div>
|
||||
<div id="footer">
|
||||
<div id="footer-text">
|
||||
Last updated 2014-04-10 14:23:11 PDT
|
||||
Last updated 2014-09-23 13:01:42 EST
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
'\" t
|
||||
.\" Title: git-map-branches
|
||||
.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
|
||||
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
|
||||
.\" Date: 04/10/2014
|
||||
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
|
||||
.\" Date: 09/23/2014
|
||||
.\" Manual: Chromium depot_tools Manual
|
||||
.\" Source: depot_tools 68b1017
|
||||
.\" Source: depot_tools 28bf2be
|
||||
.\" Language: English
|
||||
.\"
|
||||
.TH "GIT\-MAP\-BRANCHES" "1" "04/10/2014" "depot_tools 68b1017" "Chromium depot_tools Manual"
|
||||
.TH "GIT\-MAP\-BRANCHES" "1" "09/23/2014" "depot_tools 28bf2be" "Chromium depot_tools Manual"
|
||||
.\" -----------------------------------------------------------------
|
||||
.\" * Define some portability stuff
|
||||
.\" -----------------------------------------------------------------
|
||||
@@ -95,6 +95,21 @@ red
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
|
||||
\fIbranch\-heads\fR
|
||||
branches are
|
||||
blue\&.
|
||||
.RE
|
||||
.sp
|
||||
.RS 4
|
||||
.ie n \{\
|
||||
\h'-04'\(bu\h'+03'\c
|
||||
.\}
|
||||
.el \{\
|
||||
.sp -1
|
||||
.IP \(bu 2.3
|
||||
.\}
|
||||
|
||||
{NO UPSTREAM}
|
||||
is a special placeholder in
|
||||
magenta\&.
|
||||
@@ -137,13 +152,13 @@ Given the hypothetical demo repo in \fBgit-map\fR(1)\*(Aqs EXAMPLE section, and
|
||||
.\}
|
||||
.nf
|
||||
\fB$ git map\-branches\fR
|
||||
{NO_UPSTREAM}
|
||||
no_upstream
|
||||
origin/master
|
||||
cool_feature
|
||||
subfeature
|
||||
fixit
|
||||
\fB frozen_branch *
|
||||
\fR{NO UPSTREAM}
|
||||
no_upstream
|
||||
\fB frozen_branch *\fR
|
||||
.fi
|
||||
.if n \{\
|
||||
.RE
|
||||
|
||||
@@ -21,6 +21,7 @@ Git map-branches displays all local branches such that:
|
||||
(`*`) after the name.
|
||||
* Local branches are [green]#green#.
|
||||
* Remote branches are [red]#red# (usually, the root of all other branches).
|
||||
* 'branch-heads' branches are [blue]#blue#.
|
||||
* `{NO UPSTREAM}` is a special placeholder in [fuchsia]#magenta#.
|
||||
** Branches which have this as their parent are usually misconfigured, and
|
||||
should be assigned a parent by checking out the branch and running git branch
|
||||
|
||||
Reference in New Issue
Block a user