@@ -1176,7 +1176,6 @@ extension Workspace {
1176
1176
_ = try clone ( package : dependency. packageRef, at: checkoutState)
1177
1177
} else {
1178
1178
// The original dependency was removed, update the managed dependency state.
1179
- //self.state.dependencies.remove(forURL: dependency.packageRef.location)
1180
1179
self . state. dependencies. remove ( dependency. packageRef. identity)
1181
1180
try self . state. save ( )
1182
1181
}
@@ -1562,8 +1561,6 @@ extension Workspace {
1562
1561
1563
1562
/// Loads the given manifests, if it is present in the managed dependencies.
1564
1563
private func loadManagedManifests( for packages: [ PackageReference ] , diagnostics: DiagnosticsEngine , completion: @escaping ( Result < [ PackageIdentity : Manifest ] , Error > ) -> Void ) {
1565
- // this is allot of boilerplate code but its is important for performance
1566
- //let lock = Lock()
1567
1564
let sync = DispatchGroup ( )
1568
1565
let manifests = ThreadSafeKeyValueStore < PackageIdentity , Manifest > ( )
1569
1566
Set ( packages) . forEach { package in
@@ -1588,7 +1585,7 @@ extension Workspace {
1588
1585
// dependencies that have the same identity but from a different location
1589
1586
// which is an error case we diagnose an report about in the GraphLoading part which
1590
1587
// is prepared to handle the case where not all manifest are available
1591
- guard let managedDependency = self . state. dependencies [ package ] else {
1588
+ guard let managedDependency = self . state. dependencies [ comparingLocation : package ] else {
1592
1589
return completion ( . none)
1593
1590
}
1594
1591
@@ -2039,8 +2036,8 @@ extension Workspace {
2039
2036
// We require cloning if there is no checkout or if the checkout doesn't
2040
2037
// match with the pin.
2041
2038
let requiredPins = pinsStore. pins. filter { pin in
2042
- //guard let dependency = state.dependencies[forURL: pin.packageRef. location] else {
2043
- guard let dependency = state. dependencies [ pin. packageRef] else {
2039
+ // also compare the location in case it has changed
2040
+ guard let dependency = state. dependencies [ comparingLocation : pin. packageRef] else {
2044
2041
return true
2045
2042
}
2046
2043
switch dependency. state {
@@ -2416,8 +2413,8 @@ extension Workspace {
2416
2413
if case . edited( let basedOn, _) = currentDependency? . state, let originalReference = basedOn? . packageRef {
2417
2414
packageStateChanges [ originalReference. identity] = ( originalReference, . unchanged)
2418
2415
} else {
2419
- // if not edited, also lookup by location since it may have changed
2420
- currentDependency = self . state. dependencies [ packageRef]
2416
+ // if not edited, also compare by location since it may have changed
2417
+ currentDependency = self . state. dependencies [ comparingLocation : packageRef]
2421
2418
}
2422
2419
2423
2420
switch binding {
@@ -2659,7 +2656,8 @@ extension Workspace {
2659
2656
/// - Throws: If the operation could not be satisfied.
2660
2657
private func fetch( package : PackageReference ) throws -> AbsolutePath {
2661
2658
// If we already have it, fetch to update the repo from its remote.
2662
- if let dependency = self . state. dependencies [ package ] {
2659
+ // also compare the location as it may have changed
2660
+ if let dependency = self . state. dependencies [ comparingLocation: package ] {
2663
2661
let path = self . location. repositoriesCheckoutsDirectory. appending ( dependency. subpath)
2664
2662
2665
2663
// Make sure the directory is not missing (we will have to clone again
@@ -2797,7 +2795,7 @@ extension Workspace {
2797
2795
2798
2796
/// Removes the clone and checkout of the provided specifier.
2799
2797
fileprivate func remove( package : PackageReference ) throws {
2800
- guard let dependency = self . state. dependencies [ package ] else {
2798
+ guard let dependency = self . state. dependencies [ package . identity ] else {
2801
2799
throw InternalError ( " trying to remove \( package . identity) which isn't in workspace " )
2802
2800
}
2803
2801
0 commit comments