Skip to content

Commit b126edb

Browse files
committed
Rename CheckoutManager to RepositoryManager
This better conveys the intent of the class.
1 parent 57c5be1 commit b126edb

File tree

8 files changed

+59
-59
lines changed

8 files changed

+59
-59
lines changed

Sources/Commands/SwiftPackageResolveTool.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import Basic
1212
import PackageGraph
1313
import SourceControl
1414

15-
private class ResolverToolDelegate: DependencyResolverDelegate, CheckoutManagerDelegate {
15+
private class ResolverToolDelegate: DependencyResolverDelegate, RepositoryManagerDelegate {
1616
typealias Identifier = RepositoryPackageContainer.Identifier
1717

1818
func added(container identifier: Identifier) {
1919
print("note: considering repository: \(identifier.url)")
2020
}
2121

22-
func fetching(handle: CheckoutManager.RepositoryHandle, to path: AbsolutePath) {
22+
func fetching(handle: RepositoryManager.RepositoryHandle, to path: AbsolutePath) {
2323
print("note: fetching \(handle.repository.url) to \(path.asString)")
2424
}
2525
}
@@ -30,13 +30,13 @@ extension SwiftPackageTool {
3030
let manifest = try loadRootManifest(opts)
3131
let delegate = ResolverToolDelegate()
3232

33-
// Create the checkout manager.
33+
// Create the repository manager.
3434
let repositoriesPath = buildPath.appending(component: "repositories")
35-
let checkoutManager = CheckoutManager(path: repositoriesPath, provider: GitRepositoryProvider(), delegate: delegate)
35+
let repositoryManager = RepositoryManager(path: repositoriesPath, provider: GitRepositoryProvider(), delegate: delegate)
3636

3737
// Create the container provider interface.
3838
let provider = RepositoryPackageContainerProvider(
39-
checkoutManager: checkoutManager, manifestLoader: manifestLoader)
39+
repositoryManager: repositoryManager, manifestLoader: manifestLoader)
4040

4141
// Create the resolver.
4242
let resolver = DependencyResolver(provider, delegate)

Sources/Commands/Workspace.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ private class WorkspaceResolverDelegate: DependencyResolverDelegate {
4444
}
4545
}
4646

47-
private class WorkspaceCheckoutManagerDelegate: CheckoutManagerDelegate {
47+
private class WorkspaceRepositoryManagerDelegate: RepositoryManagerDelegate {
4848
unowned let workspaceDelegate: WorkspaceDelegate
4949

5050
init(workspaceDelegate: WorkspaceDelegate) {
5151
self.workspaceDelegate = workspaceDelegate
5252
}
5353

54-
func fetching(handle: CheckoutManager.RepositoryHandle, to path: AbsolutePath) {
54+
func fetching(handle: RepositoryManager.RepositoryHandle, to path: AbsolutePath) {
5555
workspaceDelegate.fetching(repository: handle.repository.url)
5656
}
5757
}
@@ -159,8 +159,8 @@ public class Workspace {
159159
/// The manifest loader to use.
160160
let manifestLoader: ManifestLoaderProtocol
161161

162-
/// The checkout manager.
163-
private let checkoutManager: CheckoutManager
162+
/// The repository manager.
163+
private let repositoryManager: RepositoryManager
164164

165165
/// The package container provider.
166166
private let containerProvider: RepositoryPackageContainerProvider
@@ -196,11 +196,11 @@ public class Workspace {
196196
self.manifestLoader = manifestLoader
197197

198198
let repositoriesPath = self.dataPath.appending(component: "repositories")
199-
self.checkoutManager = CheckoutManager(
200-
path: repositoriesPath, provider: GitRepositoryProvider(), delegate: WorkspaceCheckoutManagerDelegate(workspaceDelegate: delegate))
199+
self.repositoryManager = RepositoryManager(
200+
path: repositoriesPath, provider: GitRepositoryProvider(), delegate: WorkspaceRepositoryManagerDelegate(workspaceDelegate: delegate))
201201
self.checkoutsPath = self.dataPath.appending(component: "checkouts")
202202
self.containerProvider = RepositoryPackageContainerProvider(
203-
checkoutManager: checkoutManager, manifestLoader: manifestLoader)
203+
repositoryManager: repositoryManager, manifestLoader: manifestLoader)
204204

205205
// Ensure the cache path exists.
206206
try localFileSystem.createDirectory(repositoriesPath, recursive: true)
@@ -230,13 +230,13 @@ public class Workspace {
230230
if let dependency = dependencyMap[repository] {
231231
let path = checkoutsPath.appending(dependency.subpath)
232232
// Fetch the checkout in case there are updates available.
233-
let workingRepo = try checkoutManager.provider.openCheckout(at: path)
233+
let workingRepo = try repositoryManager.provider.openCheckout(at: path)
234234
try workingRepo.fetch()
235235
return path
236236
}
237237

238238
// If not, we need to get the repository from the checkouts.
239-
let handle = checkoutManager.lookup(repository: repository)
239+
let handle = repositoryManager.lookup(repository: repository)
240240

241241
// Wait for the repository to be fetched.
242242
let wasAvailableCondition = Condition()
@@ -285,7 +285,7 @@ public class Workspace {
285285
let path = try fetch(repository: repository)
286286

287287
// Check out the given revision.
288-
let workingRepo = try checkoutManager.provider.openCheckout(at: path)
288+
let workingRepo = try repositoryManager.provider.openCheckout(at: path)
289289
// Inform the delegate.
290290
delegate.checkingOut(repository: repository.url, at: version?.description ?? revision.identifier)
291291
try workingRepo.checkout(revision: revision)
@@ -558,7 +558,7 @@ public class Workspace {
558558
// MARK: Persistence
559559

560560
// FIXME: A lot of the persistence mechanism here is copied from
561-
// `CheckoutManager`. It would be nice to get actual infrastructure around
561+
// `RepositoryManager`. It would be nice to get actual infrastructure around
562562
// persistence to handle the boilerplate parts.
563563

564564
private enum PersistenceError: Swift.Error {

Sources/PackageGraph/RepositoryPackageContainerProvider.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ import struct PackageDescription.Version
2222
public class RepositoryPackageContainerProvider: PackageContainerProvider {
2323
public typealias Container = RepositoryPackageContainer
2424

25-
let checkoutManager: CheckoutManager
25+
let repositoryManager: RepositoryManager
2626
let manifestLoader: ManifestLoaderProtocol
2727

2828
/// Create a repository-based package provider.
2929
///
3030
/// - Parameters:
31-
/// - checkoutManager: The checkout manager responsible for providing repositories.
31+
/// - repositoryManager: The repository manager responsible for providing repositories.
3232
/// - manifestLoader: The manifest loader instance.
33-
public init(checkoutManager: CheckoutManager, manifestLoader: ManifestLoaderProtocol) {
34-
self.checkoutManager = checkoutManager
33+
public init(repositoryManager: RepositoryManager, manifestLoader: ManifestLoaderProtocol) {
34+
self.repositoryManager = repositoryManager
3535
self.manifestLoader = manifestLoader
3636
}
3737

3838
public func getContainer(for identifier: RepositorySpecifier) throws -> Container {
39-
// Resolve the container using the checkout manager.
39+
// Resolve the container using the repository manager.
4040
//
4141
// FIXME: We need to move this to an async interface, or document the interface as thread safe.
42-
let handle = checkoutManager.lookup(repository: identifier)
42+
let handle = repositoryManager.lookup(repository: identifier)
4343

4444
// Wait for the repository to be fetched.
4545
let wasAvailableCondition = Condition()

Sources/SourceControl/Repository.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public struct RepositorySpecifier: Hashable {
2626
/// unique for each repository.
2727
public var fileSystemIdentifier: String {
2828
// FIXME: Need to do something better here. In particular, we should use
29-
// a stable hash function since this interacts with the CheckoutManager
29+
// a stable hash function since this interacts with the RepositoryManager
3030
// persistence.
3131
let basename = url.components(separatedBy: "/").last!
3232
return basename + "-" + String(url.hashValue)
@@ -44,7 +44,7 @@ public func ==(lhs: RepositorySpecifier, rhs: RepositorySpecifier) -> Bool {
4444
///
4545
/// This protocol defines the lower level interface used to to access
4646
/// repositories. High-level clients should access repositories via a
47-
/// `CheckoutManager`.
47+
/// `RepositoryManager`.
4848
public protocol RepositoryProvider {
4949
/// Fetch the complete repository at the given location to `path`.
5050
///
@@ -82,13 +82,13 @@ public protocol RepositoryProvider {
8282
/// Abstract repository operations.
8383
///
8484
/// This interface provides access to an abstracted representation of a
85-
/// repository which is ultimately owned by a `CheckoutManager`. This interface
85+
/// repository which is ultimately owned by a `RepositoryManager`. This interface
8686
/// is designed in such a way as to provide the minimal facilities required by
8787
/// the package manager to gather basic information about a repository, but it
8888
/// does not aim to provide all of the interfaces one might want for working
8989
/// with an editable checkout of a repository on disk.
9090
///
91-
/// The goal of this design is to allow the `CheckoutManager` a large degree of
91+
/// The goal of this design is to allow the `RepositoryManager` a large degree of
9292
/// flexibility in the storage and maintenance of its underlying repositories.
9393
///
9494
/// This protocol is designed under the assumption that the repository can only

Sources/SourceControl/CheckoutManager.swift renamed to Sources/SourceControl/RepositoryManager.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
import Basic
1212
import Utility
1313

14-
/// Delegate to notify clients about actions being performed by CheckoutManager.
15-
public protocol CheckoutManagerDelegate: class {
14+
/// Delegate to notify clients about actions being performed by RepositoryManager.
15+
public protocol RepositoryManagerDelegate: class {
1616
/// Called when a repository is about to be fetched.
17-
func fetching(handle: CheckoutManager.RepositoryHandle, to path: AbsolutePath)
17+
func fetching(handle: RepositoryManager.RepositoryHandle, to path: AbsolutePath)
1818
}
1919

20-
/// Manages a collection of repository checkouts.
21-
public class CheckoutManager {
20+
/// Manages a collection of bare repositories.
21+
public class RepositoryManager {
2222
/// Handle to a managed repository.
2323
public class RepositoryHandle {
2424
enum Status: String {
@@ -36,7 +36,7 @@ public class CheckoutManager {
3636
}
3737

3838
/// The manager this repository is owned by.
39-
private unowned let manager: CheckoutManager
39+
private unowned let manager: RepositoryManager
4040

4141
/// The repository specifier.
4242
public let repository: RepositorySpecifier
@@ -51,14 +51,14 @@ public class CheckoutManager {
5151
fileprivate var status: Status = .uninitialized
5252

5353
/// Create a handle.
54-
fileprivate init(manager: CheckoutManager, repository: RepositorySpecifier, subpath: RelativePath) {
54+
fileprivate init(manager: RepositoryManager, repository: RepositorySpecifier, subpath: RelativePath) {
5555
self.manager = manager
5656
self.repository = repository
5757
self.subpath = subpath
5858
}
5959

6060
/// Create a handle from JSON data.
61-
fileprivate init?(manager: CheckoutManager, json data: JSON) {
61+
fileprivate init?(manager: RepositoryManager, json data: JSON) {
6262
guard case let .dictionary(contents) = data,
6363
case let .string(subpath)? = contents["subpath"],
6464
case let .string(repositoryURL)? = contents["repositoryURL"],
@@ -131,7 +131,7 @@ public class CheckoutManager {
131131
public let provider: RepositoryProvider
132132

133133
/// The delegate interface.
134-
private let delegate: CheckoutManagerDelegate
134+
private let delegate: RepositoryManagerDelegate
135135

136136
/// The map of registered repositories.
137137
//
@@ -145,7 +145,7 @@ public class CheckoutManager {
145145
/// - path: The path under which to store repositories. This should be a
146146
/// directory in which the content can be completely managed by this
147147
/// instance.
148-
public init(path: AbsolutePath, provider: RepositoryProvider, delegate: CheckoutManagerDelegate) {
148+
public init(path: AbsolutePath, provider: RepositoryProvider, delegate: RepositoryManagerDelegate) {
149149
self.path = path
150150
self.provider = provider
151151
self.delegate = delegate
@@ -265,7 +265,7 @@ public class CheckoutManager {
265265
case let .int(version)? = contents["version"] else {
266266
throw PersistenceError.unexpectedData
267267
}
268-
guard version == CheckoutManager.schemaVersion else {
268+
guard version == RepositoryManager.schemaVersion else {
269269
throw PersistenceError.invalidVersion
270270
}
271271
guard case let .array(repositoriesData)? = contents["repositories"] else {
@@ -296,7 +296,7 @@ public class CheckoutManager {
296296
/// Write the manager state to disk.
297297
private func saveState() throws {
298298
var data = [String: JSON]()
299-
data["version"] = .int(CheckoutManager.schemaVersion)
299+
data["version"] = .int(RepositoryManager.schemaVersion)
300300
// FIXME: Should record information on the provider, in case it changes.
301301
data["repositories"] = .array(repositories.map{ (key, handle) in
302302
.dictionary([
@@ -309,7 +309,7 @@ public class CheckoutManager {
309309
}
310310
}
311311

312-
extension CheckoutManager.RepositoryHandle: CustomStringConvertible {
312+
extension RepositoryManager.RepositoryHandle: CustomStringConvertible {
313313
public var description: String {
314314
return "<\(type(of: self)) subpath:\(subpath.asString)>"
315315
}

Tests/PackageGraphTests/RepositoryPackageContainerProviderTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private class MockRepositories: RepositoryProvider {
9595
}
9696
}
9797

98-
private class MockResolverDelegate: DependencyResolverDelegate, CheckoutManagerDelegate {
98+
private class MockResolverDelegate: DependencyResolverDelegate, RepositoryManagerDelegate {
9999
typealias Identifier = RepositoryPackageContainer.Identifier
100100

101101
var addedContainers: [Identifier] = []
@@ -105,7 +105,7 @@ private class MockResolverDelegate: DependencyResolverDelegate, CheckoutManagerD
105105
addedContainers.append(identifier)
106106
}
107107

108-
func fetching(handle: CheckoutManager.RepositoryHandle, to path: AbsolutePath) {
108+
func fetching(handle: RepositoryManager.RepositoryHandle, to path: AbsolutePath) {
109109
fetched += [handle.repository]
110110
}
111111
}
@@ -120,9 +120,9 @@ private struct MockDependencyResolver {
120120
self.tmpDir = try! TemporaryDirectory()
121121
self.repositories = MockRepositories(repositories: repositories)
122122
self.delegate = MockResolverDelegate()
123-
let checkoutManager = CheckoutManager(path: self.tmpDir.path, provider: self.repositories, delegate: self.delegate)
123+
let repositoryManager = RepositoryManager(path: self.tmpDir.path, provider: self.repositories, delegate: self.delegate)
124124
let provider = RepositoryPackageContainerProvider(
125-
checkoutManager: checkoutManager, manifestLoader: self.repositories.manifestLoader)
125+
repositoryManager: repositoryManager, manifestLoader: self.repositories.manifestLoader)
126126
self.resolver = DependencyResolver(provider, delegate)
127127
}
128128

Tests/SourceControlTests/CheckoutManagerTests.swift renamed to Tests/SourceControlTests/RepositoryManagerTests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import SourceControl
1515

1616
import TestSupport
1717

18-
@testable import class SourceControl.CheckoutManager
18+
@testable import class SourceControl.RepositoryManager
1919

2020
private enum DummyError: Swift.Error {
2121
case invalidRepository
@@ -73,20 +73,20 @@ private class DummyRepositoryProvider: RepositoryProvider {
7373
}
7474
}
7575

76-
private class DummyCheckoutManagerDelegate: CheckoutManagerDelegate {
76+
private class DummyRepositoryManagerDelegate: RepositoryManagerDelegate {
7777
var fetched = [RepositorySpecifier]()
7878

79-
func fetching(handle: CheckoutManager.RepositoryHandle, to path: AbsolutePath) {
79+
func fetching(handle: RepositoryManager.RepositoryHandle, to path: AbsolutePath) {
8080
fetched += [handle.repository]
8181
}
8282
}
8383

84-
class CheckoutManagerTests: XCTestCase {
84+
class RepositoryManagerTests: XCTestCase {
8585
func testBasics() throws {
8686
mktmpdir { path in
8787
let provider = DummyRepositoryProvider()
88-
let delegate = DummyCheckoutManagerDelegate()
89-
let manager = CheckoutManager(path: path, provider: provider, delegate: delegate)
88+
let delegate = DummyRepositoryManagerDelegate()
89+
let manager = RepositoryManager(path: path, provider: provider, delegate: delegate)
9090

9191
// Check that we can "fetch" a repository.
9292
let dummyRepo = RepositorySpecifier(url: "dummy")
@@ -128,8 +128,8 @@ class CheckoutManagerTests: XCTestCase {
128128
/// Check the behavior of the observer of repository status.
129129
func testObserver() {
130130
mktmpdir { path in
131-
let delegate = DummyCheckoutManagerDelegate()
132-
let manager = CheckoutManager(path: path, provider: DummyRepositoryProvider(), delegate: delegate)
131+
let delegate = DummyRepositoryManagerDelegate()
132+
let manager = RepositoryManager(path: path, provider: DummyRepositoryProvider(), delegate: delegate)
133133
let dummyRepo = RepositorySpecifier(url: "dummy")
134134
let handle = manager.lookup(repository: dummyRepo)
135135

@@ -151,8 +151,8 @@ class CheckoutManagerTests: XCTestCase {
151151

152152
// Do the initial fetch.
153153
do {
154-
let delegate = DummyCheckoutManagerDelegate()
155-
let manager = CheckoutManager(path: path, provider: provider, delegate: delegate)
154+
let delegate = DummyRepositoryManagerDelegate()
155+
let manager = RepositoryManager(path: path, provider: provider, delegate: delegate)
156156
let dummyRepo = RepositorySpecifier(url: "dummy")
157157
let handle = manager.lookup(repository: dummyRepo)
158158
XCTAssertEqual(delegate.fetched, [dummyRepo])
@@ -165,8 +165,8 @@ class CheckoutManagerTests: XCTestCase {
165165

166166
// Create a new manager, and fetch.
167167
do {
168-
let delegate = DummyCheckoutManagerDelegate()
169-
let manager = CheckoutManager(path: path, provider: provider, delegate: delegate)
168+
let delegate = DummyRepositoryManagerDelegate()
169+
let manager = RepositoryManager(path: path, provider: provider, delegate: delegate)
170170
let dummyRepo = RepositorySpecifier(url: "dummy")
171171
let handle = manager.lookup(repository: dummyRepo)
172172
// This time fetch shouldn't be called.
@@ -180,10 +180,10 @@ class CheckoutManagerTests: XCTestCase {
180180

181181
// Manually destroy the manager state, and check it still works.
182182
do {
183-
let delegate = DummyCheckoutManagerDelegate()
184-
var manager = CheckoutManager(path: path, provider: provider, delegate: delegate)
183+
let delegate = DummyRepositoryManagerDelegate()
184+
var manager = RepositoryManager(path: path, provider: provider, delegate: delegate)
185185
try! removeFileTree(manager.statePath)
186-
manager = CheckoutManager(path: path, provider: provider, delegate: delegate)
186+
manager = RepositoryManager(path: path, provider: provider, delegate: delegate)
187187
let dummyRepo = RepositorySpecifier(url: "dummy")
188188
let handle = manager.lookup(repository: dummyRepo)
189189
XCTAssertEqual(delegate.fetched, [dummyRepo])

Tests/SourceControlTests/XCTestManifests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import XCTest
1313
#if !os(macOS)
1414
public func allTests() -> [XCTestCaseEntry] {
1515
return [
16-
testCase(CheckoutManagerTests.allTests),
16+
testCase(RepositoryManagerTests.allTests),
1717
testCase(GitRepositoryTests.allTests),
1818
]
1919
}

0 commit comments

Comments
 (0)