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