Skip to content

Fix force resolved versions for transitive local dependencies #3691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

neonichu
Copy link
Contributor

Previously we were pre-populating managed dependencies with only the first level of dependencies from roots. Now we will do this before attempting to load manifests to ensure this works recursively.

Motivation:

Make the force resolved versions mode work for cases where local dependencies are used in packages other than the roots.

Modifications:

  • Deleted the pre-populating code _resolveToResolvedVersion
  • Introduce a new parameter to loadDependencyManifests to enable automatically adding local packages to managed dependencies if we are in the force resolved versions mode

I considered two alternative changes:

  • Remove local packages from managed dependencies, since we don't really need them there in order to load their manifests. This proved to be a pretty substantial change, though, so I discarded it.
  • Changing the pre-populating code to be recursive. This works, but seemed wasteful as we would need to iterate over the whole graph an additional time for no good reason.

Result:

The force resolved versions mode works for cases where local dependencies are used in packages other than the roots.

Previously we were pre-populating managed dependencies with only the first level of dependencies from roots. Now we will do this before attempting to load manifests to ensure this works recursively.

rdar://82397606
@neonichu neonichu force-pushed the fix-resolved-versions-for-transitive-local-dependencies branch from c983fa6 to bba493c Compare August 26, 2021 18:06
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

// Save state for local packages, if any.
//
// FIXME: This will only work for top-level local packages right now.
for rootManifest in rootManifests.values {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the reason this can be removed is that the dependenciesRequired above always already contain all the root manifests?

Copy link
Contributor Author

@neonichu neonichu Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's right, we are already processing the direct dependencies of the roots there, no need to do it twice. The roots themselves do not end up in managed dependencies.

@neonichu neonichu self-assigned this Aug 27, 2021
@abertelrud abertelrud self-requested a review August 27, 2021 04:05
Copy link
Contributor

@abertelrud abertelrud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@neonichu neonichu merged commit 7d02c35 into main Aug 27, 2021
@neonichu neonichu deleted the fix-resolved-versions-for-transitive-local-dependencies branch August 27, 2021 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants