From b555d966397d3038940bbe7ffbbb12623a8d72fb Mon Sep 17 00:00:00 2001 From: Alan Velasco Date: Thu, 7 Jun 2018 18:44:22 -0700 Subject: [PATCH] Remove duplicated class and unused import --- src/python/pants/init/engine_initializer.py | 4 -- .../pants/init/target_roots_calculator.py | 68 ------------------- 2 files changed, 72 deletions(-) diff --git a/src/python/pants/init/engine_initializer.py b/src/python/pants/init/engine_initializer.py index 4e5a7a63b55..9eefeefbfcd 100644 --- a/src/python/pants/init/engine_initializer.py +++ b/src/python/pants/init/engine_initializer.py @@ -27,10 +27,6 @@ from pants.engine.rules import SingletonRule from pants.engine.scheduler import Scheduler from pants.option.global_options import GlobMatchErrorBehavior -<<<<<<< 84084e918921aec1294ffcb77d8c5d0e69921a38 -======= -from pants.option.options_bootstrapper import OptionsBootstrapper ->>>>>>> Remove changed_calculator targets and dependencies from pants.util.objects import datatype diff --git a/src/python/pants/init/target_roots_calculator.py b/src/python/pants/init/target_roots_calculator.py index ee5f149b507..d483e3a9e8a 100644 --- a/src/python/pants/init/target_roots_calculator.py +++ b/src/python/pants/init/target_roots_calculator.py @@ -24,74 +24,6 @@ logger = logging.getLogger(__name__) -class _DependentGraph(object): - """A graph for walking dependent addresses of TargetAdaptor objects. - - This avoids/imitates constructing a v1 BuildGraph object, because that codepath results - in many references held in mutable global state (ie, memory leaks). - - The long term goal is to deprecate the `changed` goal in favor of sufficiently good cache - hit rates, such that rather than running: - - ./pants --changed-parent=master test - - ...you would always be able to run: - - ./pants test :: - - ...and have it complete in a similar amount of time by hitting relevant caches. - """ - - @classmethod - def from_iterable(cls, target_types, adaptor_iter): - """Create a new DependentGraph from an iterable of TargetAdaptor subclasses.""" - inst = cls(target_types) - for target_adaptor in adaptor_iter: - inst.inject_target(target_adaptor) - return inst - - def __init__(self, target_types): - self._dependent_address_map = defaultdict(set) - self._target_types = target_types - - def inject_target(self, target_adaptor): - """Inject a target, respecting all sources of dependencies.""" - target_cls = self._target_types[target_adaptor.type_alias] - - declared_deps = target_adaptor.dependencies - implicit_deps = (Address.parse(s) - for s in target_cls.compute_dependency_specs(kwargs=target_adaptor.kwargs())) - - for dep in itertools.chain(declared_deps, implicit_deps): - self._dependent_address_map[dep].add(target_adaptor.address) - - def dependents_of_addresses(self, addresses): - """Given an iterable of addresses, yield all of those addresses dependents.""" - seen = set(addresses) - for address in addresses: - for dependent_address in self._dependent_address_map[address]: - if dependent_address not in seen: - seen.add(dependent_address) - yield dependent_address - - def transitive_dependents_of_addresses(self, addresses): - """Given an iterable of addresses, yield all of those addresses dependents, transitively.""" - addresses_to_visit = set(addresses) - while 1: - dependents = set(self.dependents_of_addresses(addresses)) - # If we've exhausted all dependencies or visited all remaining nodes, break. - if (not dependents) or dependents.issubset(addresses_to_visit): - break - addresses = dependents.difference(addresses_to_visit) - addresses_to_visit.update(dependents) - - transitive_set = itertools.chain( - *(self._dependent_address_map[address] for address in addresses_to_visit) - ) - for dep in transitive_set: - yield dep - - class _DependentGraph(object): """A graph for walking dependent addresses of TargetAdaptor objects.