| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, status) = status_info.next() |
| 139 self.__status_info[branch] = (url, color); | 139 self.__status_info[branch] = (url, color_for_status(status)) |
| 140 | 140 |
| 141 roots = set() | 141 roots = set() |
| 142 | 142 |
| 143 # A map of parents to a list of their children. | 143 # A map of parents to a list of their children. |
| 144 for branch, branch_info in self.__branches_info.iteritems(): | 144 for branch, branch_info in self.__branches_info.iteritems(): |
| 145 if not branch_info: | 145 if not branch_info: |
| 146 continue | 146 continue |
| 147 | 147 |
| 148 parent = branch_info.upstream | 148 parent = branch_info.upstream |
| 149 if not self.__branches_info[parent]: | 149 if not self.__branches_info[parent]: |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 mapper.start() | 301 mapper.start() |
| 302 print mapper.output.as_formatted_string() | 302 print mapper.output.as_formatted_string() |
| 303 return 0 | 303 return 0 |
| 304 | 304 |
| 305 if __name__ == '__main__': | 305 if __name__ == '__main__': |
| 306 try: | 306 try: |
| 307 sys.exit(main(sys.argv[1:])) | 307 sys.exit(main(sys.argv[1:])) |
| 308 except KeyboardInterrupt: | 308 except KeyboardInterrupt: |
| 309 sys.stderr.write('interrupted\n') | 309 sys.stderr.write('interrupted\n') |
| 310 sys.exit(1) | 310 sys.exit(1) |
| OLD | NEW |