Skip to content

Commit

Permalink
Do not fetch VCS deps when reference didn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
maksbotan committed Aug 7, 2022
1 parent 601dc78 commit 4519884
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/poetry/mixology/version_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def _get_min(dependency: Dependency) -> tuple[bool, int]:
else:
package = locked

package = self._provider.complete_package(package)
package = self._provider.complete_package(package, get_locked=self._get_locked)

conflict = False
for incompatibility in self._provider.incompatibilities_for(package):
Expand Down
22 changes: 21 additions & 1 deletion src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from collections.abc import Callable
from collections.abc import Iterable
from collections.abc import Iterator
from typing import Protocol

from cleo.io.io import IO
from poetry.core.packages.dependency import Dependency
Expand Down Expand Up @@ -508,7 +509,10 @@ def incompatibilities_for(
]

def complete_package(
self, dependency_package: DependencyPackage
self,
dependency_package: DependencyPackage,
*,
get_locked: GetLocked | None = None,
) -> DependencyPackage:
package = dependency_package.package
dependency = dependency_package.dependency
Expand Down Expand Up @@ -553,6 +557,13 @@ def complete_package(
# Retrieving constraints for deferred dependencies
for r in requires:
if r.is_direct_origin():
if get_locked is not None:
locked = get_locked(r, allow_similar=False)
# If lock file contains exactly the same URL and reference
# (commit hash) of dependency as is requested,
# do not analyze it again: nothing could have changed.
if locked is not None and locked.package.is_same_package_as(r):
continue
self.search_for_direct_origin_dependency(r)

optional_dependencies = []
Expand Down Expand Up @@ -957,3 +968,12 @@ def _merge_dependencies_by_marker(
)
deps.append(_deps[0].with_constraint(new_constraint))
return deps


if TYPE_CHECKING:

class GetLocked(Protocol):
def __call__(
self, dependency: Dependency, *, allow_similar: bool = False
) -> DependencyPackage | None:
...

0 comments on commit 4519884

Please sign in to comment.