| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly. | 5 # Monkeypatch IMapIterator so that Ctrl-C can kill everything properly. |
| 6 # Derived from https://gist.github.com/aljungberg/626518 | 6 # Derived from https://gist.github.com/aljungberg/626518 |
| 7 import multiprocessing.pool | 7 import multiprocessing.pool |
| 8 from multiprocessing.pool import IMapIterator | 8 from multiprocessing.pool import IMapIterator |
| 9 def wrapper(func): | 9 def wrapper(func): |
| 10 def wrap(self, timeout=None): | 10 def wrap(self, timeout=None): |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 """Return {branch: <|option| value>} for all branches.""" | 286 """Return {branch: <|option| value>} for all branches.""" |
| 287 try: | 287 try: |
| 288 reg = re.compile(r'^branch\.(.*)\.%s$' % option) | 288 reg = re.compile(r'^branch\.(.*)\.%s$' % option) |
| 289 lines = run('config', '--get-regexp', reg.pattern).splitlines() | 289 lines = run('config', '--get-regexp', reg.pattern).splitlines() |
| 290 return {reg.match(k).group(1): v for k, v in (l.split() for l in lines)} | 290 return {reg.match(k).group(1): v for k, v in (l.split() for l in lines)} |
| 291 except subprocess2.CalledProcessError: | 291 except subprocess2.CalledProcessError: |
| 292 return {} | 292 return {} |
| 293 | 293 |
| 294 | 294 |
| 295 def branches(*args): | 295 def branches(*args): |
| 296 NO_BRANCH = ('* (no branch', '* (detached from ') | 296 NO_BRANCH = ('* (no branch', '* (detached', '* (HEAD detached') |
| 297 | 297 |
| 298 key = 'depot-tools.branch-limit' | 298 key = 'depot-tools.branch-limit' |
| 299 limit = 20 | 299 limit = 20 |
| 300 try: | 300 try: |
| 301 limit = int(config(key, limit)) | 301 limit = int(config(key, limit)) |
| 302 except ValueError: | 302 except ValueError: |
| 303 pass | 303 pass |
| 304 | 304 |
| 305 raw_branches = run('branch', *args).splitlines() | 305 raw_branches = run('branch', *args).splitlines() |
| 306 | 306 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) | 787 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) |
| 788 | 788 |
| 789 # Set None for upstreams which are not branches (e.g empty upstream, remotes | 789 # Set None for upstreams which are not branches (e.g empty upstream, remotes |
| 790 # and deleted upstream branches). | 790 # and deleted upstream branches). |
| 791 missing_upstreams = {} | 791 missing_upstreams = {} |
| 792 for info in info_map.values(): | 792 for info in info_map.values(): |
| 793 if info.upstream not in info_map and info.upstream not in missing_upstreams: | 793 if info.upstream not in info_map and info.upstream not in missing_upstreams: |
| 794 missing_upstreams[info.upstream] = None | 794 missing_upstreams[info.upstream] = None |
| 795 | 795 |
| 796 return dict(info_map.items() + missing_upstreams.items()) | 796 return dict(info_map.items() + missing_upstreams.items()) |
| OLD | NEW |