diff --git a/manager_test.go b/manager_test.go index adaf50b3..09f84971 100644 --- a/manager_test.go +++ b/manager_test.go @@ -107,7 +107,7 @@ func TestProjectManagerInit(t *testing.T) { // Two birds, one stone - make sure the internal ProjectManager vlist cache // works by asking for the versions again, and do it through smcache to // ensure its sorting works, as well. - smc := &smcache{ + smc := &smAdapter{ sm: sm, vlists: make(map[ProjectName][]Version), } diff --git a/sm_cache.go b/sm_adapter.go similarity index 89% rename from sm_cache.go rename to sm_adapter.go index 4bc76118..c60c3028 100644 --- a/sm_cache.go +++ b/sm_adapter.go @@ -2,7 +2,7 @@ package vsolver import "sort" -// smcache is a pseudo-decorator around a proper SourceManager. +// smAdapter is an adapter and around a proper SourceManager. // // It provides localized caching that's tailored to the requirements of a // particular solve run. @@ -13,8 +13,8 @@ import "sort" // the complexities of deciding what a particular name "means" entirely within // the solver, while the SourceManager can traffic exclusively in // globally-unique network names. -type smcache struct { - // The decorated/underlying SourceManager +type smAdapter struct { + // The underlying, adapted-to SourceManager sm SourceManager // Direction to sort the version list. False indicates sorting for upgrades; // true for downgrades. @@ -26,11 +26,11 @@ type smcache struct { vlists map[ProjectName][]Version } -func (c *smcache) getProjectInfo(pa ProjectAtom) (ProjectInfo, error) { +func (c *smAdapter) getProjectInfo(pa ProjectAtom) (ProjectInfo, error) { return c.sm.GetProjectInfo(pa) } -func (c *smcache) listVersions(n ProjectName) ([]Version, error) { +func (c *smAdapter) listVersions(n ProjectName) ([]Version, error) { if vl, exists := c.vlists[n]; exists { return vl, nil } @@ -51,11 +51,11 @@ func (c *smcache) listVersions(n ProjectName) ([]Version, error) { return vl, nil } -func (c *smcache) repoExists(n ProjectName) (bool, error) { +func (c *smAdapter) repoExists(n ProjectName) (bool, error) { return c.sm.RepoExists(n) } -func (c *smcache) vendorCodeExists(n ProjectName) (bool, error) { +func (c *smAdapter) vendorCodeExists(n ProjectName) (bool, error) { return c.sm.VendorCodeExists(n) } diff --git a/solver.go b/solver.go index 59980da9..0233c354 100644 --- a/solver.go +++ b/solver.go @@ -37,7 +37,7 @@ func NewSolver(sm SourceManager, l *logrus.Logger) Solver { } return &solver{ - sm: &smcache{sm: sm}, + sm: &smAdapter{sm: sm}, l: l, latest: make(map[ProjectName]struct{}), rlm: make(map[ProjectName]LockedProject), @@ -49,7 +49,7 @@ func NewSolver(sm SourceManager, l *logrus.Logger) Solver { type solver struct { l *logrus.Logger o SolveOpts - sm *smcache + sm *smAdapter latest map[ProjectName]struct{} sel *selection unsel *unselected @@ -84,7 +84,7 @@ func (s *solver) Solve(opts SolveOpts) (Result, error) { //return Result{}, fmt.Errorf("Project root must be a directory.") //} - // Init/reset the smcache + // Init/reset the smAdapter s.sm.sortdown = opts.Downgrade s.sm.vlists = make(map[ProjectName][]Version) diff --git a/version_queue.go b/version_queue.go index 488022bf..a133a7f9 100644 --- a/version_queue.go +++ b/version_queue.go @@ -14,12 +14,12 @@ type versionQueue struct { ref ProjectName pi []Version fails []failedVersion - sm *smcache + sm *smAdapter failed bool hasLock, allLoaded bool } -func newVersionQueue(ref ProjectName, lockv ProjectAtom, sm *smcache) (*versionQueue, error) { +func newVersionQueue(ref ProjectName, lockv ProjectAtom, sm *smAdapter) (*versionQueue, error) { vq := &versionQueue{ ref: ref, sm: sm,