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

Side by Side Diff: git_map_branches.py

Issue 1176213003: Fix git-map-branches coloration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Provides a short mapping of all the branches in your local repo, organized 6 """Provides a short mapping of all the branches in your local repo, organized
7 by their upstream ('tracking branch') layout. 7 by their upstream ('tracking branch') layout.
8 8
9 Example: 9 Example:
10 origin/master 10 origin/master
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 self.__current_branch = None 119 self.__current_branch = None
120 self.__current_hash = None 120 self.__current_hash = None
121 self.__tag_set = None 121 self.__tag_set = None
122 self.__status_info = {} 122 self.__status_info = {}
123 123
124 def start(self): 124 def start(self):
125 self.__branches_info = get_branches_info( 125 self.__branches_info = get_branches_info(
126 include_tracking_status=self.verbosity >= 1) 126 include_tracking_status=self.verbosity >= 1)
127 if (self.verbosity >= 2): 127 if (self.verbosity >= 2):
128 # Avoid heavy import unless necessary. 128 # Avoid heavy import unless necessary.
129 from git_cl import get_cl_statuses 129 from git_cl import get_cl_statuses, color_for_status
130 130
131 status_info = get_cl_statuses(self.__branches_info.keys(), 131 status_info = get_cl_statuses(self.__branches_info.keys(),
132 fine_grained=self.verbosity > 2, 132 fine_grained=self.verbosity > 2,
133 max_processes=self.maxjobs) 133 max_processes=self.maxjobs)
134 134
135 for _ in xrange(len(self.__branches_info)): 135 for _ in xrange(len(self.__branches_info)):
136 # This is a blocking get which waits for the remote CL status to be 136 # This is a blocking get which waits for the remote CL status to be
137 # retrieved. 137 # retrieved.
138 (branch, url, color) = status_info.next() 138 (branch, url, color) = status_info.next()
139 self.__status_info[branch] = (url, color); 139 color = color_for_status(color)
140 self.__status_info[branch] = (url, color)
140 141
141 roots = set() 142 roots = set()
142 143
143 # A map of parents to a list of their children. 144 # A map of parents to a list of their children.
144 for branch, branch_info in self.__branches_info.iteritems(): 145 for branch, branch_info in self.__branches_info.iteritems():
145 if not branch_info: 146 if not branch_info:
146 continue 147 continue
147 148
148 parent = branch_info.upstream 149 parent = branch_info.upstream
149 if not self.__branches_info[parent]: 150 if not self.__branches_info[parent]:
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 mapper.start() 302 mapper.start()
302 print mapper.output.as_formatted_string() 303 print mapper.output.as_formatted_string()
303 return 0 304 return 0
304 305
305 if __name__ == '__main__': 306 if __name__ == '__main__':
306 try: 307 try:
307 sys.exit(main(sys.argv[1:])) 308 sys.exit(main(sys.argv[1:]))
308 except KeyboardInterrupt: 309 except KeyboardInterrupt:
309 sys.stderr.write('interrupted\n') 310 sys.stderr.write('interrupted\n')
310 sys.exit(1) 311 sys.exit(1)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698