Skip to content

Commit 33cc5e5

Browse files
committed
Remove unused ManagedDependency property subpath
1 parent c3ec774 commit 33cc5e5

File tree

4 files changed

+29
-63
lines changed

4 files changed

+29
-63
lines changed

Sources/Workspace/ManagedDependency.swift

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,11 @@ extension Workspace {
5454
return false
5555
}
5656

57-
/// The checked out path of the dependency on disk, relative to the workspace checkouts path.
58-
public let subpath: RelativePath
59-
6057
internal init(
6158
packageRef: PackageReference,
62-
state: State,
63-
subpath: RelativePath
59+
state: State
6460
) {
6561
self.packageRef = packageRef
66-
self.subpath = subpath
6762
self.state = state
6863
}
6964

@@ -73,8 +68,8 @@ extension Workspace {
7368
/// - Parameters:
7469
/// - subpath: The subpath inside the editable directory.
7570
/// - unmanagedPath: A custom absolute path instead of the subpath.
76-
public func edited(subpath: RelativePath, unmanagedPath: AbsolutePath?) -> ManagedDependency {
77-
return .edited(packageRef: self.packageRef, subpath: subpath, basedOn: self, unmanagedPath: unmanagedPath)
71+
public func edited(unmanagedPath: AbsolutePath?) -> ManagedDependency {
72+
return .edited(packageRef: self.packageRef, basedOn: self, unmanagedPath: unmanagedPath)
7873
}
7974

8075
/// Create a dependency present locally on the filesystem.
@@ -83,36 +78,30 @@ extension Workspace {
8378
) -> ManagedDependency {
8479
return ManagedDependency(
8580
packageRef: packageRef,
86-
state: .local,
87-
// FIXME: This is just a fake entry, we should fix it.
88-
subpath: RelativePath(packageRef.identity.description)
81+
state: .local
8982
)
9083
}
9184

9285
/// Create a remote dependency checked out
9386
public static func remote(
9487
packageRef: PackageReference,
95-
state: CheckoutState,
96-
subpath: RelativePath
88+
state: CheckoutState
9789
) -> ManagedDependency {
9890
return ManagedDependency(
9991
packageRef: packageRef,
100-
state: .checkout(state),
101-
subpath: subpath
92+
state: .checkout(state)
10293
)
10394
}
10495

10596
/// Create an edited dependency
10697
public static func edited(
10798
packageRef: PackageReference,
108-
subpath: RelativePath,
10999
basedOn: ManagedDependency?,
110100
unmanagedPath: AbsolutePath?
111101
) -> ManagedDependency {
112102
return ManagedDependency(
113103
packageRef: packageRef,
114-
state: .edited(basedOn: basedOn, unmanagedPath: unmanagedPath),
115-
subpath: subpath
104+
state: .edited(basedOn: basedOn, unmanagedPath: unmanagedPath)
116105
)
117106
}
118107
}

Sources/Workspace/Workspace.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ extension Workspace {
11191119

11201120
// Save the new state.
11211121
self.state.dependencies.add(
1122-
dependency.edited(subpath: RelativePath(packageName), unmanagedPath: path)
1122+
dependency.edited(unmanagedPath: path)
11231123
)
11241124
try self.state.save()
11251125
}
@@ -2753,8 +2753,7 @@ extension Workspace {
27532753
// Write the state record.
27542754
self.state.dependencies.add(.remote(
27552755
packageRef: package,
2756-
state: checkoutState,
2757-
subpath: path.relative(to: self.location.repositoriesCheckoutsDirectory)
2756+
state: checkoutState
27582757
))
27592758
try self.state.save()
27602759

@@ -2833,7 +2832,6 @@ extension Workspace {
28332832
dependencyToRemove = basedOn
28342833
let updatedDependency = Workspace.ManagedDependency.edited(
28352834
packageRef: dependency.packageRef,
2836-
subpath: dependency.subpath,
28372835
basedOn: .none,
28382836
unmanagedPath: unmanagedPath
28392837
)

Sources/Workspace/WorkspaceState.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,24 +159,20 @@ fileprivate struct WorkspaceStateStorage {
159159
struct Dependency: Codable {
160160
let packageRef: PackageReference
161161
let state: State
162-
let subpath: String
163162

164-
init(packageRef: PackageReference, state: State, subpath: String) {
163+
init(packageRef: PackageReference, state: State) {
165164
self.packageRef = packageRef
166165
self.state = state
167-
self.subpath = subpath
168166
}
169167

170168
init(_ dependency: Workspace.ManagedDependency) {
171169
self.packageRef = .init(dependency.packageRef)
172170
self.state = .init(underlying: dependency.state)
173-
self.subpath = dependency.subpath.pathString
174171
}
175172

176173
init(from decoder: Decoder) throws {
177174
let container = try decoder.container(keyedBy: CodingKeys.self)
178175
let packageRef = try container.decode(PackageReference.self, forKey: .packageRef)
179-
let subpath = try container.decode(String.self, forKey: .subpath)
180176
let basedOn = try container.decode(Dependency?.self, forKey: .basedOn)
181177
let state = try State.decode(
182178
container: container.nestedContainer(keyedBy: State.CodingKeys.self, forKey: .state),
@@ -185,16 +181,14 @@ fileprivate struct WorkspaceStateStorage {
185181

186182
self.init(
187183
packageRef: packageRef,
188-
state: state,
189-
subpath: subpath
184+
state: state
190185
)
191186
}
192187

193188
func encode(to encoder: Encoder) throws {
194189
var container = encoder.container(keyedBy: CodingKeys.self)
195190
try container.encode(self.packageRef, forKey: .packageRef)
196191
try container.encode(self.state, forKey: .state)
197-
try container.encode(self.subpath, forKey: .subpath)
198192
var basedOn: Dependency? = .none
199193
if case .edited(let _basedOn, _) = self.state.underlying {
200194
basedOn = _basedOn.map { .init($0) }
@@ -372,8 +366,7 @@ extension Workspace.ManagedDependency {
372366
fileprivate init(_ dependency: WorkspaceStateStorage.V4.Dependency) throws {
373367
try self.init(
374368
packageRef: .init(dependency.packageRef),
375-
state: dependency.state.underlying,
376-
subpath: RelativePath(dependency.subpath)
369+
state: dependency.state.underlying
377370
)
378371
}
379372
}

Tests/WorkspaceTests/WorkspaceTests.swift

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,6 @@ final class WorkspaceTests: XCTestCase {
794794
func testPrecomputeResolution_empty() throws {
795795
let sandbox = AbsolutePath("/tmp/ws/")
796796
let fs = InMemoryFileSystem()
797-
let bPath = RelativePath("B")
798797
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
799798
let v2 = CheckoutState.version("2.0.0", revision: Revision(identifier: "hello"))
800799

@@ -819,8 +818,8 @@ final class WorkspaceTests: XCTestCase {
819818
try workspace.set(
820819
pins: [bRef: v1_5, cRef: v2],
821820
managedDependencies: [
822-
.remote(packageRef: bRef, state: v1_5, subpath: bPath)
823-
.edited(subpath: bPath, unmanagedPath: .none),
821+
.remote(packageRef: bRef, state: v1_5)
822+
.edited(unmanagedPath: .none),
824823
]
825824
)
826825

@@ -833,7 +832,6 @@ final class WorkspaceTests: XCTestCase {
833832
func testPrecomputeResolution_newPackages() throws {
834833
let sandbox = AbsolutePath("/tmp/ws/")
835834
let fs = InMemoryFileSystem()
836-
let bPath = RelativePath("B")
837835
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
838836
let v1 = CheckoutState.version("1.0.0", revision: Revision(identifier: "hello"))
839837

@@ -875,7 +873,7 @@ final class WorkspaceTests: XCTestCase {
875873
try workspace.set(
876874
pins: [bRef: v1],
877875
managedDependencies: [
878-
.remote(packageRef: bRef, state: v1, subpath: bPath),
876+
.remote(packageRef: bRef, state: v1),
879877
]
880878
)
881879

@@ -888,8 +886,6 @@ final class WorkspaceTests: XCTestCase {
888886
func testPrecomputeResolution_requirementChange_versionToBranch() throws {
889887
let sandbox = AbsolutePath("/tmp/ws/")
890888
let fs = InMemoryFileSystem()
891-
let bPath = RelativePath("B")
892-
let cPath = RelativePath("C")
893889
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
894890
let branchRequirement: MockDependency.Requirement = .branch("master")
895891
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
@@ -932,8 +928,8 @@ final class WorkspaceTests: XCTestCase {
932928
try workspace.set(
933929
pins: [bRef: v1_5, cRef: v1_5],
934930
managedDependencies: [
935-
.remote(packageRef: bRef, state: v1_5, subpath: bPath),
936-
.remote(packageRef: cRef, state: v1_5, subpath: cPath),
931+
.remote(packageRef: bRef, state: v1_5),
932+
.remote(packageRef: cRef, state: v1_5),
937933
]
938934
)
939935

@@ -950,7 +946,6 @@ final class WorkspaceTests: XCTestCase {
950946
func testPrecomputeResolution_requirementChange_versionToRevision() throws {
951947
let sandbox = AbsolutePath("/tmp/ws/")
952948
let fs = InMemoryFileSystem()
953-
let cPath = RelativePath("C")
954949
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
955950

956951
let testWorkspace = try MockWorkspace(
@@ -982,7 +977,7 @@ final class WorkspaceTests: XCTestCase {
982977
try testWorkspace.set(
983978
pins: [cRef: v1_5],
984979
managedDependencies: [
985-
.remote(packageRef: cRef, state: v1_5, subpath: cPath),
980+
.remote(packageRef: cRef, state: v1_5),
986981
]
987982
)
988983

@@ -999,7 +994,6 @@ final class WorkspaceTests: XCTestCase {
999994
func testPrecomputeResolution_requirementChange_localToBranch() throws {
1000995
let sandbox = AbsolutePath("/tmp/ws/")
1001996
let fs = InMemoryFileSystem()
1002-
let bPath = RelativePath("B")
1003997
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
1004998
let masterRequirement: MockDependency.Requirement = .branch("master")
1005999
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
@@ -1042,7 +1036,7 @@ final class WorkspaceTests: XCTestCase {
10421036
try workspace.set(
10431037
pins: [bRef: v1_5],
10441038
managedDependencies: [
1045-
.remote(packageRef: bRef, state: v1_5, subpath: bPath),
1039+
.remote(packageRef: bRef, state: v1_5),
10461040
.local(packageRef: cRef),
10471041
]
10481042
)
@@ -1060,8 +1054,6 @@ final class WorkspaceTests: XCTestCase {
10601054
func testPrecomputeResolution_requirementChange_versionToLocal() throws {
10611055
let sandbox = AbsolutePath("/tmp/ws/")
10621056
let fs = InMemoryFileSystem()
1063-
let bPath = RelativePath("B")
1064-
let cPath = RelativePath("C")
10651057
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
10661058
//let localRequirement: MockDependency.Requirement = .localPackage
10671059
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
@@ -1104,8 +1096,8 @@ final class WorkspaceTests: XCTestCase {
11041096
try workspace.set(
11051097
pins: [bRef: v1_5, cRef: v1_5],
11061098
managedDependencies: [
1107-
.remote(packageRef: bRef, state: v1_5, subpath: bPath),
1108-
.remote(packageRef: cRef, state: v1_5, subpath: cPath),
1099+
.remote(packageRef: bRef, state: v1_5),
1100+
.remote(packageRef: cRef, state: v1_5),
11091101
]
11101102
)
11111103

@@ -1122,8 +1114,6 @@ final class WorkspaceTests: XCTestCase {
11221114
func testPrecomputeResolution_requirementChange_branchToLocal() throws {
11231115
let sandbox = AbsolutePath("/tmp/ws/")
11241116
let fs = InMemoryFileSystem()
1125-
let bPath = RelativePath("B")
1126-
let cPath = RelativePath("C")
11271117
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
11281118
//let localRequirement: MockDependency.Requirement = .localPackage
11291119
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
@@ -1168,8 +1158,8 @@ final class WorkspaceTests: XCTestCase {
11681158
try workspace.set(
11691159
pins: [bRef: v1_5, cRef: master],
11701160
managedDependencies: [
1171-
.remote(packageRef: bRef, state: v1_5, subpath: bPath),
1172-
.remote(packageRef: cRef, state: master, subpath: cPath),
1161+
.remote(packageRef: bRef, state: v1_5),
1162+
.remote(packageRef: cRef, state: master),
11731163
]
11741164
)
11751165

@@ -1186,8 +1176,6 @@ final class WorkspaceTests: XCTestCase {
11861176
func testPrecomputeResolution_other() throws {
11871177
let sandbox = AbsolutePath("/tmp/ws/")
11881178
let fs = InMemoryFileSystem()
1189-
let bPath = RelativePath("B")
1190-
let cPath = RelativePath("C")
11911179
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
11921180
let v2Requirement: MockDependency.Requirement = .range("2.0.0" ..< "3.0.0")
11931181
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
@@ -1230,8 +1218,8 @@ final class WorkspaceTests: XCTestCase {
12301218
try workspace.set(
12311219
pins: [bRef: v1_5, cRef: v1_5],
12321220
managedDependencies: [
1233-
.remote(packageRef: bRef, state: v1_5, subpath: bPath),
1234-
.remote(packageRef: cRef, state: v1_5, subpath: cPath),
1221+
.remote(packageRef: bRef, state: v1_5),
1222+
.remote(packageRef: cRef, state: v1_5),
12351223
]
12361224
)
12371225

@@ -1244,8 +1232,6 @@ final class WorkspaceTests: XCTestCase {
12441232
func testPrecomputeResolution_notRequired() throws {
12451233
let sandbox = AbsolutePath("/tmp/ws/")
12461234
let fs = InMemoryFileSystem()
1247-
let bPath = RelativePath("B")
1248-
let cPath = RelativePath("C")
12491235
let v1Requirement: MockDependency.Requirement = .range("1.0.0" ..< "2.0.0")
12501236
let v2Requirement: MockDependency.Requirement = .range("2.0.0" ..< "3.0.0")
12511237
let v1_5 = CheckoutState.version("1.0.5", revision: Revision(identifier: "hello"))
@@ -1289,8 +1275,8 @@ final class WorkspaceTests: XCTestCase {
12891275
try workspace.set(
12901276
pins: [bRef: v1_5, cRef: v2],
12911277
managedDependencies: [
1292-
.remote(packageRef: bRef, state: v1_5, subpath: bPath),
1293-
.remote(packageRef: cRef, state: v2, subpath: cPath),
1278+
.remote(packageRef: bRef, state: v1_5),
1279+
.remote(packageRef: cRef, state: v2),
12941280
]
12951281
)
12961282

@@ -5020,7 +5006,7 @@ final class WorkspaceTests: XCTestCase {
50205006
let aRepo = workspace.repoProvider.specifierMap[RepositorySpecifier(path: aPath)]!
50215007
let aRevision = try aRepo.resolveRevision(tag: "1.0.0")
50225008
let aState = CheckoutState.version("1.0.0", revision: aRevision)
5023-
let aDependency: Workspace.ManagedDependency = .remote(packageRef: aRef, state: aState, subpath: RelativePath("A"))
5009+
let aDependency: Workspace.ManagedDependency = .remote(packageRef: aRef, state: aState)
50245010

50255011
try workspace.set(
50265012
pins: [aRef: aState],
@@ -5430,7 +5416,7 @@ final class WorkspaceTests: XCTestCase {
54305416
let aRepo = workspace.repoProvider.specifierMap[RepositorySpecifier(path: aPath)]!
54315417
let aRevision = try aRepo.resolveRevision(tag: "1.0.0")
54325418
let aState = CheckoutState.version("1.0.0", revision: aRevision)
5433-
let aDependency: Workspace.ManagedDependency = .remote(packageRef: aRef, state: aState, subpath: RelativePath("A"))
5419+
let aDependency: Workspace.ManagedDependency = .remote(packageRef: aRef, state: aState)
54345420

54355421
try workspace.set(
54365422
pins: [aRef: aState],

0 commit comments

Comments
 (0)