| 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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 | 393 |
| 394 def get_or_create_merge_base(branch, parent=None): | 394 def get_or_create_merge_base(branch, parent=None): |
| 395 """Finds the configured merge base for branch. | 395 """Finds the configured merge base for branch. |
| 396 | 396 |
| 397 If parent is supplied, it's used instead of calling upstream(branch). | 397 If parent is supplied, it's used instead of calling upstream(branch). |
| 398 """ | 398 """ |
| 399 base = branch_config(branch, 'base') | 399 base = branch_config(branch, 'base') |
| 400 base_upstream = branch_config(branch, 'base-upstream') | 400 base_upstream = branch_config(branch, 'base-upstream') |
| 401 parent = parent or upstream(branch) | 401 parent = parent or upstream(branch) |
| 402 if not parent: | 402 if parent is None or branch is None: |
| 403 return None | 403 return None |
| 404 actual_merge_base = run('merge-base', parent, branch) | 404 actual_merge_base = run('merge-base', parent, branch) |
| 405 | 405 |
| 406 if base_upstream != parent: | 406 if base_upstream != parent: |
| 407 base = None | 407 base = None |
| 408 base_upstream = None | 408 base_upstream = None |
| 409 | 409 |
| 410 def is_ancestor(a, b): | 410 def is_ancestor(a, b): |
| 411 return run_with_retcode('merge-base', '--is-ancestor', a, b) == 0 | 411 return run_with_retcode('merge-base', '--is-ancestor', a, b) == 0 |
| 412 | 412 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) | 762 hash=branch_hash, upstream=upstream_branch, ahead=ahead, behind=behind) |
| 763 | 763 |
| 764 # Set None for upstreams which are not branches (e.g empty upstream, remotes | 764 # Set None for upstreams which are not branches (e.g empty upstream, remotes |
| 765 # and deleted upstream branches). | 765 # and deleted upstream branches). |
| 766 missing_upstreams = {} | 766 missing_upstreams = {} |
| 767 for info in info_map.values(): | 767 for info in info_map.values(): |
| 768 if info.upstream not in info_map and info.upstream not in missing_upstreams: | 768 if info.upstream not in info_map and info.upstream not in missing_upstreams: |
| 769 missing_upstreams[info.upstream] = None | 769 missing_upstreams[info.upstream] = None |
| 770 | 770 |
| 771 return dict(info_map.items() + missing_upstreams.items()) | 771 return dict(info_map.items() + missing_upstreams.items()) |
| OLD | NEW |