changed_request = ChangedRequest.from_options(changed_options)
// Determine the `--owner-of=` arguments provided from the global options
owned_files = options.for_global_scope().owner_of
logger.debug("spec_roots are: %s", spec_roots)
logger.debug("changed_request is: %s", changed_request)
logger.debug("owned_files are: %s", owned_files)
scm = get_scm()
change_calculator = ChangeCalculator(session, symbol_table, scm) if scm else None
owner_calculator = OwnerCalculator(session, symbol_table) if owned_files else None
targets_specified = sum(1 for item
in (changed_request.is_actionable(), owned_files, spec_roots)
if item)
if targets_specified > 1:
// We"ve been provided a more than one of: a change request, an owner request, or spec roots.
raise InvalidSpecConstraint(
"Multiple target selection methods provided. Please use only one of "
"--changed-*, --owner-of, or target specs"
)
if change_calculator and changed_request.is_actionable():
// We"ve been provided no spec roots (e.g. `./pants list`) AND a changed request. Compute
// alternate target roots.
changed_addresses = change_calculator.changed_target_addresses(changed_request)
logger.debug("changed addresses: %s", changed_addresses)
return TargetRoots(tuple(SingleAddress(a.spec_path, a.target_name) for a in changed_addresses))
if owner_calculator and owned_files:
// We"ve been provided no spec roots (e.g. `./pants list`) AND a owner request. Compute
// alternate target roots.
owner_addresses = owner_calculator.owner_target_addresses(owned_files)
logger.debug("owner addresses: %s", owner_addresses)
return TargetRoots(tuple(SingleAddress(a.spec_path, a.target_name) for a in owner_addresses))
return TargetRoots(spec_roots)
class ChangeCalculator(object):