OLD | NEW |
---|---|
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 self.__current_branch = None | 121 self.__current_branch = None |
122 self.__current_hash = None | 122 self.__current_hash = None |
123 self.__tag_set = None | 123 self.__tag_set = None |
124 self.__status_info = {} | 124 self.__status_info = {} |
125 | 125 |
126 def start(self): | 126 def start(self): |
127 self.__branches_info = get_branches_info( | 127 self.__branches_info = get_branches_info( |
128 include_tracking_status=self.verbosity >= 1) | 128 include_tracking_status=self.verbosity >= 1) |
129 if (self.verbosity >= 2): | 129 if (self.verbosity >= 2): |
130 # Avoid heavy import unless necessary. | 130 # Avoid heavy import unless necessary. |
131 from git_cl import get_cl_statuses, color_for_status | 131 from git_cl import get_cl_statuses, color_for_status, Changelist |
132 | 132 |
133 status_info = get_cl_statuses(self.__branches_info.keys(), | 133 change_cls = [Changelist(branchref='refs/heads/'+b) |
134 for b in self.__branches_info.keys()] | |
135 status_info = get_cl_statuses(change_cls, | |
134 fine_grained=self.verbosity > 2, | 136 fine_grained=self.verbosity > 2, |
135 max_processes=self.maxjobs) | 137 max_processes=self.maxjobs) |
136 | 138 |
137 for _ in xrange(len(self.__branches_info)): | 139 for _ in xrange(len(self.__branches_info)): |
tandrii(chromium)
2016/05/20 20:56:06
for _ in self.__branches_info:
would work just fi
| |
138 # This is a blocking get which waits for the remote CL status to be | 140 # This is a blocking get which waits for the remote CL status to be |
139 # retrieved. | 141 # retrieved. |
140 (branch, url, status) = status_info.next() | 142 (cl, status) = status_info.next() |
141 self.__status_info[branch] = (url, color_for_status(status)) | 143 self.__status_info[cl.GetBranch()] = (cl.GetIssueURL(), |
144 color_for_status(status)) | |
142 | 145 |
143 roots = set() | 146 roots = set() |
144 | 147 |
145 # A map of parents to a list of their children. | 148 # A map of parents to a list of their children. |
146 for branch, branch_info in self.__branches_info.iteritems(): | 149 for branch, branch_info in self.__branches_info.iteritems(): |
147 if not branch_info: | 150 if not branch_info: |
148 continue | 151 continue |
149 | 152 |
150 parent = branch_info.upstream | 153 parent = branch_info.upstream |
151 if not self.__branches_info[parent]: | 154 if not self.__branches_info[parent]: |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 mapper.start() | 306 mapper.start() |
304 print mapper.output.as_formatted_string() | 307 print mapper.output.as_formatted_string() |
305 return 0 | 308 return 0 |
306 | 309 |
307 if __name__ == '__main__': | 310 if __name__ == '__main__': |
308 try: | 311 try: |
309 sys.exit(main(sys.argv[1:])) | 312 sys.exit(main(sys.argv[1:])) |
310 except KeyboardInterrupt: | 313 except KeyboardInterrupt: |
311 sys.stderr.write('interrupted\n') | 314 sys.stderr.write('interrupted\n') |
312 sys.exit(1) | 315 sys.exit(1) |
OLD | NEW |