Skip to content

Commit ac5d561

Browse files
authored
use identity in workspace state tracking (#3741)
motivation: use identity everywhere we can as locaiton will be deprecated as we trasnition toward regsitry based dependencies changes: change workspace::packageStateChanges to be identity based rdar://82954076
1 parent 272b72d commit ac5d561

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

Sources/Workspace/Workspace.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,7 +2393,7 @@ extension Workspace {
23932393
) throws -> [(PackageReference, PackageStateChange)] {
23942394
// Load pins store and managed dependendencies.
23952395
let pinsStore = try self.pinsStore.load()
2396-
var packageStateChanges: [String: (PackageReference, PackageStateChange)] = [:]
2396+
var packageStateChanges: [PackageIdentity: (PackageReference, PackageStateChange)] = [:]
23972397

23982398
// Set the states from resolved dependencies results.
23992399
for (packageRef, binding, products) in resolvedDependencies {
@@ -2416,7 +2416,7 @@ extension Workspace {
24162416
}) {
24172417
currentDependency = editedDependency
24182418
let originalReference = editedDependency.basedOn!.packageRef // forced unwrap safe
2419-
packageStateChanges[originalReference.location] = (originalReference, .unchanged)
2419+
packageStateChanges[originalReference.identity] = (originalReference, .unchanged)
24202420
} else {
24212421
currentDependency = nil
24222422
}
@@ -2435,14 +2435,14 @@ extension Workspace {
24352435
if let currentDependency = currentDependency {
24362436
switch currentDependency.state {
24372437
case .local, .edited:
2438-
packageStateChanges[packageRef.location] = (packageRef, .unchanged)
2438+
packageStateChanges[packageRef.identity] = (packageRef, .unchanged)
24392439
case .checkout:
24402440
let newState = PackageStateChange.State(requirement: .unversioned, products: products)
2441-
packageStateChanges[packageRef.location] = (packageRef, .updated(newState))
2441+
packageStateChanges[packageRef.identity] = (packageRef, .updated(newState))
24422442
}
24432443
} else {
24442444
let newState = PackageStateChange.State(requirement: .unversioned, products: products)
2445-
packageStateChanges[packageRef.location] = (packageRef, .added(newState))
2445+
packageStateChanges[packageRef.identity] = (packageRef, .added(newState))
24462446
}
24472447

24482448
case .revision(let identifier, let branch):
@@ -2475,34 +2475,34 @@ extension Workspace {
24752475
newState = .revision(revision)
24762476
}
24772477
if case .checkout(let checkoutState) = currentDependency.state, checkoutState == newState {
2478-
packageStateChanges[packageRef.location] = (packageRef, .unchanged)
2478+
packageStateChanges[packageRef.identity] = (packageRef, .unchanged)
24792479
} else {
24802480
// Otherwise, we need to update this dependency to this revision.
24812481
let newState = PackageStateChange.State(requirement: .revision(revision, branch: branch), products: products)
2482-
packageStateChanges[packageRef.location] = (packageRef, .updated(newState))
2482+
packageStateChanges[packageRef.identity] = (packageRef, .updated(newState))
24832483
}
24842484
} else {
24852485
let newState = PackageStateChange.State(requirement: .revision(revision, branch: branch), products: products)
2486-
packageStateChanges[packageRef.location] = (packageRef, .added(newState))
2486+
packageStateChanges[packageRef.identity] = (packageRef, .added(newState))
24872487
}
24882488

24892489
case .version(let version):
24902490
if let currentDependency = currentDependency {
24912491
if case .checkout(let checkoutState) = currentDependency.state, case .version(version, _) = checkoutState {
2492-
packageStateChanges[packageRef.location] = (packageRef, .unchanged)
2492+
packageStateChanges[packageRef.identity] = (packageRef, .unchanged)
24932493
} else {
24942494
let newState = PackageStateChange.State(requirement: .version(version), products: products)
2495-
packageStateChanges[packageRef.location] = (packageRef, .updated(newState))
2495+
packageStateChanges[packageRef.identity] = (packageRef, .updated(newState))
24962496
}
24972497
} else {
24982498
let newState = PackageStateChange.State(requirement: .version(version), products: products)
2499-
packageStateChanges[packageRef.location] = (packageRef, .added(newState))
2499+
packageStateChanges[packageRef.identity] = (packageRef, .added(newState))
25002500
}
25012501
}
25022502
}
25032503
// Set the state of any old package that might have been removed.
2504-
for packageRef in state.dependencies.lazy.map({ $0.packageRef }) where packageStateChanges[packageRef.location] == nil {
2505-
packageStateChanges[packageRef.location] = (packageRef, .removed)
2504+
for packageRef in state.dependencies.lazy.map({ $0.packageRef }) where packageStateChanges[packageRef.identity] == nil {
2505+
packageStateChanges[packageRef.identity] = (packageRef, .removed)
25062506
}
25072507

25082508
return Array(packageStateChanges.values)

0 commit comments

Comments
 (0)