5971e20c7d1d76b57f11cea31d2ecd234fc48723,src/python/pants/init/target_roots_calculator.py,TargetRootsCalculator,create,#Any#Any#Any#Any#Any#,116

Before Change


    change_calculator = ChangeCalculator(session, symbol_table, scm) if scm else None

    if change_calculator and changed_request.is_actionable():
      if spec_roots:
        // We"ve been provided spec roots (e.g. `./pants list ::`) AND a changed request. Error out.
        raise InvalidSpecConstraint("cannot provide changed parameters and target specs!")

      // 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))

After Change


    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):
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: pantsbuild/pants
Commit Name: 5971e20c7d1d76b57f11cea31d2ecd234fc48723
Time: 2018-06-08
Author: AlanVelasco.A@gmail.com
File Name: src/python/pants/init/target_roots_calculator.py
Class Name: TargetRootsCalculator
Method Name: create


Project Name: pantsbuild/pants
Commit Name: f4cf055ae16b2af7247a2288542e9cfd2608c775
Time: 2019-11-07
Author: benjyw@gmail.com
File Name: src/python/pants/help/help_printer.py
Class Name: HelpPrinter
Method Name: _print_goals_help


Project Name: pantsbuild/pants
Commit Name: 9506fbf0dbf8c4436c2ef808a4ceed4679c2488f
Time: 2020-05-12
Author: stuhood@twitter.com
File Name: src/python/pants/bin/local_pants_runner.py
Class Name: LocalPantsRunner
Method Name: _maybe_run_v2