зеркало из https://github.com/golang/dep.git
s/smcache/smAdapter/
This commit is contained in:
Родитель
b812a4ce18
Коммит
e00401fdae
|
@ -107,7 +107,7 @@ func TestProjectManagerInit(t *testing.T) {
|
||||||
// Two birds, one stone - make sure the internal ProjectManager vlist cache
|
// Two birds, one stone - make sure the internal ProjectManager vlist cache
|
||||||
// works by asking for the versions again, and do it through smcache to
|
// works by asking for the versions again, and do it through smcache to
|
||||||
// ensure its sorting works, as well.
|
// ensure its sorting works, as well.
|
||||||
smc := &smcache{
|
smc := &smAdapter{
|
||||||
sm: sm,
|
sm: sm,
|
||||||
vlists: make(map[ProjectName][]Version),
|
vlists: make(map[ProjectName][]Version),
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package vsolver
|
||||||
|
|
||||||
import "sort"
|
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
|
// It provides localized caching that's tailored to the requirements of a
|
||||||
// particular solve run.
|
// particular solve run.
|
||||||
|
@ -13,8 +13,8 @@ import "sort"
|
||||||
// the complexities of deciding what a particular name "means" entirely within
|
// the complexities of deciding what a particular name "means" entirely within
|
||||||
// the solver, while the SourceManager can traffic exclusively in
|
// the solver, while the SourceManager can traffic exclusively in
|
||||||
// globally-unique network names.
|
// globally-unique network names.
|
||||||
type smcache struct {
|
type smAdapter struct {
|
||||||
// The decorated/underlying SourceManager
|
// The underlying, adapted-to SourceManager
|
||||||
sm SourceManager
|
sm SourceManager
|
||||||
// Direction to sort the version list. False indicates sorting for upgrades;
|
// Direction to sort the version list. False indicates sorting for upgrades;
|
||||||
// true for downgrades.
|
// true for downgrades.
|
||||||
|
@ -26,11 +26,11 @@ type smcache struct {
|
||||||
vlists map[ProjectName][]Version
|
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)
|
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 {
|
if vl, exists := c.vlists[n]; exists {
|
||||||
return vl, nil
|
return vl, nil
|
||||||
}
|
}
|
||||||
|
@ -51,11 +51,11 @@ func (c *smcache) listVersions(n ProjectName) ([]Version, error) {
|
||||||
return vl, nil
|
return vl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *smcache) repoExists(n ProjectName) (bool, error) {
|
func (c *smAdapter) repoExists(n ProjectName) (bool, error) {
|
||||||
return c.sm.RepoExists(n)
|
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)
|
return c.sm.VendorCodeExists(n)
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func NewSolver(sm SourceManager, l *logrus.Logger) Solver {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &solver{
|
return &solver{
|
||||||
sm: &smcache{sm: sm},
|
sm: &smAdapter{sm: sm},
|
||||||
l: l,
|
l: l,
|
||||||
latest: make(map[ProjectName]struct{}),
|
latest: make(map[ProjectName]struct{}),
|
||||||
rlm: make(map[ProjectName]LockedProject),
|
rlm: make(map[ProjectName]LockedProject),
|
||||||
|
@ -49,7 +49,7 @@ func NewSolver(sm SourceManager, l *logrus.Logger) Solver {
|
||||||
type solver struct {
|
type solver struct {
|
||||||
l *logrus.Logger
|
l *logrus.Logger
|
||||||
o SolveOpts
|
o SolveOpts
|
||||||
sm *smcache
|
sm *smAdapter
|
||||||
latest map[ProjectName]struct{}
|
latest map[ProjectName]struct{}
|
||||||
sel *selection
|
sel *selection
|
||||||
unsel *unselected
|
unsel *unselected
|
||||||
|
@ -84,7 +84,7 @@ func (s *solver) Solve(opts SolveOpts) (Result, error) {
|
||||||
//return Result{}, fmt.Errorf("Project root must be a directory.")
|
//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.sortdown = opts.Downgrade
|
||||||
s.sm.vlists = make(map[ProjectName][]Version)
|
s.sm.vlists = make(map[ProjectName][]Version)
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@ type versionQueue struct {
|
||||||
ref ProjectName
|
ref ProjectName
|
||||||
pi []Version
|
pi []Version
|
||||||
fails []failedVersion
|
fails []failedVersion
|
||||||
sm *smcache
|
sm *smAdapter
|
||||||
failed bool
|
failed bool
|
||||||
hasLock, allLoaded 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{
|
vq := &versionQueue{
|
||||||
ref: ref,
|
ref: ref,
|
||||||
sm: sm,
|
sm: sm,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче