@@ -25,6 +25,7 @@ import struct PackageGraph.Assignment
25
25
import enum PackageGraph. BoundVersion
26
26
import enum PackageGraph. ContainerUpdateStrategy
27
27
import protocol PackageGraph. CustomPackageContainer
28
+ import struct PackageGraph. DependencyResolverBinding
28
29
import protocol PackageGraph. DependencyResolverDelegate
29
30
import struct PackageGraph. Incompatibility
30
31
import struct PackageGraph. MultiplexResolverDelegate
@@ -631,7 +632,7 @@ extension Workspace {
631
632
@discardableResult
632
633
fileprivate func updateDependenciesCheckouts(
633
634
root: PackageGraphRoot ,
634
- updateResults: [ ( PackageReference , BoundVersion , ProductFilter ) ] ,
635
+ updateResults: [ DependencyResolverBinding ] ,
635
636
updateBranches: Bool = false ,
636
637
observabilityScope: ObservabilityScope
637
638
) -> [ ( PackageReference , PackageStateChange ) ] {
@@ -954,7 +955,7 @@ extension Workspace {
954
955
/// Computes states of the packages based on last stored state.
955
956
fileprivate func computePackageStateChanges(
956
957
root: PackageGraphRoot ,
957
- resolvedDependencies: [ ( PackageReference , BoundVersion , ProductFilter ) ] ,
958
+ resolvedDependencies: [ DependencyResolverBinding ] ,
958
959
updateBranches: Bool ,
959
960
observabilityScope: ObservabilityScope
960
961
) throws -> [ ( PackageReference , PackageStateChange ) ] {
@@ -963,59 +964,59 @@ extension Workspace {
963
964
var packageStateChanges : [ PackageIdentity : ( PackageReference , PackageStateChange ) ] = [ : ]
964
965
965
966
// Set the states from resolved dependencies results.
966
- for (packageRef , binding, products ) in resolvedDependencies {
967
+ for binding in resolvedDependencies {
967
968
// Get the existing managed dependency for this package ref, if any.
968
969
969
970
// first find by identity only since edit location may be different by design
970
- var currentDependency = self . state. dependencies [ packageRef . identity]
971
+ var currentDependency = self . state. dependencies [ binding . package . identity]
971
972
// Check if this is an edited dependency.
972
973
if case . edited( let basedOn, _) = currentDependency? . state, let originalReference = basedOn? . packageRef {
973
974
packageStateChanges [ originalReference. identity] = ( originalReference, . unchanged)
974
975
} else {
975
976
// if not edited, also compare by location since it may have changed
976
- currentDependency = self . state. dependencies [ comparingLocation: packageRef ]
977
+ currentDependency = self . state. dependencies [ comparingLocation: binding . package ]
977
978
}
978
979
979
- switch binding {
980
+ switch binding. boundVersion {
980
981
case . excluded:
981
982
throw InternalError ( " Unexpected excluded binding " )
982
983
983
984
case . unversioned:
984
985
// Ignore the root packages.
985
- if root. packages. keys. contains ( packageRef . identity) {
986
+ if root. packages. keys. contains ( binding . package . identity) {
986
987
continue
987
988
}
988
989
989
990
if let currentDependency {
990
991
switch currentDependency. state {
991
992
case . fileSystem, . edited:
992
- packageStateChanges [ packageRef . identity] = ( packageRef , . unchanged)
993
+ packageStateChanges [ binding . package . identity] = ( binding . package , . unchanged)
993
994
case . sourceControlCheckout:
994
- let newState = PackageStateChange . State ( requirement: . unversioned, products: products)
995
- packageStateChanges [ packageRef . identity] = ( packageRef , . updated( newState) )
995
+ let newState = PackageStateChange . State ( requirement: . unversioned, products: binding . products)
996
+ packageStateChanges [ binding . package . identity] = ( binding . package , . updated( newState) )
996
997
case . registryDownload:
997
998
throw InternalError ( " Unexpected unversioned binding for downloaded dependency " )
998
999
case . custom:
999
1000
throw InternalError ( " Unexpected unversioned binding for custom dependency " )
1000
1001
}
1001
1002
} else {
1002
- let newState = PackageStateChange . State ( requirement: . unversioned, products: products)
1003
- packageStateChanges [ packageRef . identity] = ( packageRef , . added( newState) )
1003
+ let newState = PackageStateChange . State ( requirement: . unversioned, products: binding . products)
1004
+ packageStateChanges [ binding . package . identity] = ( binding . package , . added( newState) )
1004
1005
}
1005
1006
1006
1007
case . revision( let identifier, let branch) :
1007
1008
// Get the latest revision from the container.
1008
1009
// TODO: replace with async/await when available
1009
1010
guard let container = try ( temp_await {
1010
1011
packageContainerProvider. getContainer (
1011
- for: packageRef ,
1012
+ for: binding . package ,
1012
1013
updateStrategy: . never,
1013
1014
observabilityScope: observabilityScope,
1014
1015
on: . sharedConcurrent,
1015
1016
completion: $0
1016
1017
)
1017
1018
} ) as? SourceControlPackageContainer else {
1018
- throw InternalError ( " invalid container for \( packageRef ) expected a SourceControlPackageContainer " )
1019
+ throw InternalError ( " invalid container for \( binding . package ) expected a SourceControlPackageContainer " )
1019
1020
}
1020
1021
var revision = try container. getRevision ( forIdentifier: identifier)
1021
1022
let branch = branch ?? ( identifier == revision. identifier ? nil : identifier)
@@ -1024,7 +1025,7 @@ extension Workspace {
1024
1025
// branches, use the revision from pin instead (if present).
1025
1026
if branch != nil , !updateBranches {
1026
1027
if case . branch( branch, let pinRevision) = pinsStore. pins. values
1027
- . first ( where: { $0. packageRef == packageRef } ) ? . state
1028
+ . first ( where: { $0. packageRef == binding . package } ) ? . state
1028
1029
{
1029
1030
revision = Revision ( identifier: pinRevision)
1030
1031
}
@@ -1043,21 +1044,21 @@ extension Workspace {
1043
1044
if case . sourceControlCheckout( let checkoutState) = currentDependency. state,
1044
1045
checkoutState == newState
1045
1046
{
1046
- packageStateChanges [ packageRef . identity] = ( packageRef , . unchanged)
1047
+ packageStateChanges [ binding . package . identity] = ( binding . package , . unchanged)
1047
1048
} else {
1048
1049
// Otherwise, we need to update this dependency to this revision.
1049
1050
let newState = PackageStateChange . State (
1050
1051
requirement: . revision( revision, branch: branch) ,
1051
- products: products
1052
+ products: binding . products
1052
1053
)
1053
- packageStateChanges [ packageRef . identity] = ( packageRef , . updated( newState) )
1054
+ packageStateChanges [ binding . package . identity] = ( binding . package , . updated( newState) )
1054
1055
}
1055
1056
} else {
1056
1057
let newState = PackageStateChange . State (
1057
1058
requirement: . revision( revision, branch: branch) ,
1058
- products: products
1059
+ products: binding . products
1059
1060
)
1060
- packageStateChanges [ packageRef . identity] = ( packageRef , . added( newState) )
1061
+ packageStateChanges [ binding . package . identity] = ( binding . package , . added( newState) )
1061
1062
}
1062
1063
1063
1064
case . version( let version) :
@@ -1066,11 +1067,11 @@ extension Workspace {
1066
1067
case . sourceControlCheckout( . version( version, _) ) , . registryDownload( version) , . custom( version, _) :
1067
1068
stateChange = . unchanged
1068
1069
case . edited, . fileSystem, . sourceControlCheckout, . registryDownload, . custom:
1069
- stateChange = . updated( . init( requirement: . version( version) , products: products) )
1070
+ stateChange = . updated( . init( requirement: . version( version) , products: binding . products) )
1070
1071
case nil :
1071
- stateChange = . added( . init( requirement: . version( version) , products: products) )
1072
+ stateChange = . added( . init( requirement: . version( version) , products: binding . products) )
1072
1073
}
1073
- packageStateChanges [ packageRef . identity] = ( packageRef , stateChange)
1074
+ packageStateChanges [ binding . package . identity] = ( binding . package , stateChange)
1074
1075
}
1075
1076
}
1076
1077
// Set the state of any old package that might have been removed.
@@ -1114,7 +1115,7 @@ extension Workspace {
1114
1115
resolver: PubGrubDependencyResolver ,
1115
1116
constraints: [ PackageContainerConstraint ] ,
1116
1117
observabilityScope: ObservabilityScope
1117
- ) -> [ ( package : PackageReference , binding : BoundVersion , products : ProductFilter ) ] {
1118
+ ) -> [ DependencyResolverBinding ] {
1118
1119
os_signpost ( . begin, name: SignpostName . pubgrub)
1119
1120
let result = resolver. solve ( constraints: constraints)
1120
1121
os_signpost ( . end, name: SignpostName . pubgrub)
@@ -1179,7 +1180,7 @@ private struct WorkspaceDependencyResolverDelegate: DependencyResolverDelegate {
1179
1180
difference: Term
1180
1181
) { }
1181
1182
func failedToResolve( incompatibility: Incompatibility ) { }
1182
- func solved( result: [ ( package : PackageReference , binding : BoundVersion , products : ProductFilter ) ] ) { }
1183
+ func solved( result: [ DependencyResolverBinding ] ) { }
1183
1184
}
1184
1185
1185
1186
// FIXME: the manifest loading logic should be changed to use identity instead of location once identity is unique
0 commit comments