| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 change_cls = [Changelist(branchref='refs/heads/'+b) | 133 change_cls = [Changelist(branchref='refs/heads/'+b) |
| 134 for b in self.__branches_info.keys() if b] | 134 for b in self.__branches_info.keys() if b] |
| 135 status_info = get_cl_statuses(change_cls, | 135 status_info = get_cl_statuses(change_cls, |
| 136 fine_grained=self.verbosity > 2, | 136 fine_grained=self.verbosity > 2, |
| 137 max_processes=self.maxjobs) | 137 max_processes=self.maxjobs) |
| 138 | 138 |
| 139 # This is a blocking get which waits for the remote CL status to be | 139 # This is a blocking get which waits for the remote CL status to be |
| 140 # retrieved. | 140 # retrieved. |
| 141 for cl, status in status_info: | 141 for cl, status in status_info: |
| 142 self.__status_info[cl.GetBranch()] = (cl.GetIssueURL(), | 142 self.__status_info[cl.GetBranch()] = (cl.GetIssueURL(), |
| 143 color_for_status(status)) | 143 color_for_status(status), |
| 144 status) |
| 144 | 145 |
| 145 roots = set() | 146 roots = set() |
| 146 | 147 |
| 147 # A map of parents to a list of their children. | 148 # A map of parents to a list of their children. |
| 148 for branch, branch_info in self.__branches_info.iteritems(): | 149 for branch, branch_info in self.__branches_info.iteritems(): |
| 149 if not branch_info: | 150 if not branch_info: |
| 150 continue | 151 continue |
| 151 | 152 |
| 152 parent = branch_info.upstream | 153 parent = branch_info.upstream |
| 153 if not self.__branches_info[parent]: | 154 if not self.__branches_info[parent]: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 center_separator = '|' | 254 center_separator = '|' |
| 254 | 255 |
| 255 line.append(front_separator, separator=' ') | 256 line.append(front_separator, separator=' ') |
| 256 line.append(ahead_string, separator=' ', color=Fore.MAGENTA) | 257 line.append(ahead_string, separator=' ', color=Fore.MAGENTA) |
| 257 line.append(center_separator, separator=' ') | 258 line.append(center_separator, separator=' ') |
| 258 line.append(behind_string, separator=' ', color=Fore.MAGENTA) | 259 line.append(behind_string, separator=' ', color=Fore.MAGENTA) |
| 259 line.append(back_separator) | 260 line.append(back_separator) |
| 260 | 261 |
| 261 # The Rietveld issue associated with the branch. | 262 # The Rietveld issue associated with the branch. |
| 262 if self.verbosity >= 2: | 263 if self.verbosity >= 2: |
| 263 (url, color) = ('', '') if self.__is_invalid_parent(branch) \ | 264 (url, color, status) = ('', '', '') if self.__is_invalid_parent(branch) \ |
| 264 else self.__status_info[branch] | 265 else self.__status_info[branch] |
| 265 line.append(url or '', color=color) | 266 if self.verbosity > 2: |
| 267 line.append('{} ({})'.format(url, status) if url else '', color=color) |
| 268 else: |
| 269 line.append(url or '', color=color) |
| 266 | 270 |
| 267 # The subject of the most recent commit on the branch. | 271 # The subject of the most recent commit on the branch. |
| 268 if self.show_subject: | 272 if self.show_subject: |
| 269 line.append(run('log', '-n1', '--format=%s', branch)) | 273 line.append(run('log', '-n1', '--format=%s', branch)) |
| 270 | 274 |
| 271 self.output.append(line) | 275 self.output.append(line) |
| 272 | 276 |
| 273 for child in sorted(self.__parent_map.pop(branch, ())): | 277 for child in sorted(self.__parent_map.pop(branch, ())): |
| 274 self.__append_branch(child, depth=depth + 1) | 278 self.__append_branch(child, depth=depth + 1) |
| 275 | 279 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 305 mapper.start() | 309 mapper.start() |
| 306 print mapper.output.as_formatted_string() | 310 print mapper.output.as_formatted_string() |
| 307 return 0 | 311 return 0 |
| 308 | 312 |
| 309 if __name__ == '__main__': | 313 if __name__ == '__main__': |
| 310 try: | 314 try: |
| 311 sys.exit(main(sys.argv[1:])) | 315 sys.exit(main(sys.argv[1:])) |
| 312 except KeyboardInterrupt: | 316 except KeyboardInterrupt: |
| 313 sys.stderr.write('interrupted\n') | 317 sys.stderr.write('interrupted\n') |
| 314 sys.exit(1) | 318 sys.exit(1) |
| OLD | NEW |