Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Introduce source concept within SourceManager #83

Merged
merged 71 commits into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
24a208a
Rename errors.go to make space for sm errors
sdboyer Jul 28, 2016
51077e1
Convert SourceManager to use on ProjectIdentifier
sdboyer Jul 28, 2016
c557321
Have sourceBridge compose SourceManager
sdboyer Jul 28, 2016
8c226cd
Buncha type renames; short tests now passing again
sdboyer Jul 29, 2016
d6ebd9d
Refactor setup of projectManager instances
sdboyer Jul 29, 2016
4bbb0e4
Revamp project managers for new type inputs
sdboyer Jul 30, 2016
680c996
Add possible schemes by vcs in remote deduction
sdboyer Aug 1, 2016
4cb9bcb
Fix shadowed variable assignment
sdboyer Aug 1, 2016
cfa2b1f
Look at dashed paths, now
sdboyer Aug 1, 2016
50171a4
Windows-friendly filepath join (hopefully)
sdboyer Aug 1, 2016
90a4e17
Store the right repo path
sdboyer Aug 1, 2016
445948e
Add whatsInAName; a cache around deduction
sdboyer Aug 1, 2016
7c516b8
Incremental refactor of remoteRepo
sdboyer Aug 2, 2016
6a1d540
Incremental move towards 'source'
sdboyer Aug 2, 2016
3311597
Revert "Incremental refactor of remoteRepo"
sdboyer Aug 2, 2016
6562383
Add commented mutexes on data cache
sdboyer Aug 2, 2016
84b91f7
Pull most of projectManager over into baseSource
sdboyer Aug 2, 2016
fa87665
First of source tests
sdboyer Aug 2, 2016
abd11df
Fix up git version parsing
sdboyer Aug 2, 2016
e46e3d4
Only use map to deduplicate
sdboyer Aug 2, 2016
98e9a02
Fix ordering issues in gitSource tests
sdboyer Aug 2, 2016
41344d1
Add revisionPresentIn() impl to baseSource
sdboyer Aug 2, 2016
c5d7e9a
s/projectDataCache/sourceMetaCache/
sdboyer Aug 2, 2016
43d62a8
Move maybes into their own file
sdboyer Aug 3, 2016
4c8445c
Touchups around gitSource
sdboyer Aug 3, 2016
a7b9a60
Add bzrSource and maybeBzrSource
sdboyer Aug 3, 2016
858aeae
Small bugfixes in bzrSource.listVersions()
sdboyer Aug 3, 2016
c53563b
Add basic tests for bzrSource
sdboyer Aug 3, 2016
72f1e0f
Add tests for hgSource
sdboyer Aug 3, 2016
56a6369
Add hgSource implementation, plus the maybe
sdboyer Aug 3, 2016
eda0de9
Add note to README about source inference choice
sdboyer Aug 3, 2016
fb085c7
Use UnpairedVersion in sourceMetaCache
sdboyer Aug 3, 2016
c72c3d6
Refactor baseSource to use UnpairedV in metacache
sdboyer Aug 3, 2016
d62bc08
At least make projectManager compile again
sdboyer Aug 3, 2016
7fdd4c4
Forgot to try to rederive Revision after syncing
sdboyer Aug 3, 2016
631f708
s/baseSource/baseVCSSource/
sdboyer Aug 3, 2016
e57f311
Move vcs source subtypes into their own file
sdboyer Aug 3, 2016
4072c90
Remove build.Context entirely from SourceMgr
sdboyer Aug 4, 2016
6f5bcdd
Add sourceFailures to hold multiple try() fails
sdboyer Aug 5, 2016
058b587
Introduce futures for import path interpretation
sdboyer Aug 5, 2016
fc7f8a7
Fail immediately if test can't load a project
sdboyer Aug 5, 2016
6f40c2d
Get rid of unnecessary interface/struct for return
sdboyer Aug 5, 2016
621d3ba
Get rid of unnecessary futurizing funcs
sdboyer Aug 5, 2016
ada3344
Several type naming improvements
sdboyer Aug 5, 2016
0b08955
Don't return futures from pathDeducers
sdboyer Aug 5, 2016
b891176
Add gopkg.in/yaml special case
sdboyer Aug 5, 2016
aaa9390
Convert remote deduction fixtures (todo: checking)
sdboyer Aug 8, 2016
32658fb
Compat comments; use an explicit type on return
sdboyer Aug 8, 2016
ca638c4
Implement checking for new
sdboyer Aug 9, 2016
449ec87
Fix all the new import path deduction unit tests
sdboyer Aug 10, 2016
593b12f
s/RepoExists()/SourceExists()/
sdboyer Aug 10, 2016
149ef63
Add deducerTrie (typed wrapper of radix.Tree)
sdboyer Aug 11, 2016
1bc2469
Introduce deductionFuture for deduction results
sdboyer Aug 11, 2016
6cfedc3
Also return string ident from sourceFuture
sdboyer Aug 12, 2016
c2e8b10
Add helper func for creating SourceMgr w/tmp dir
sdboyer Aug 13, 2016
b663ae8
Add typed radix trie for project roots
sdboyer Aug 14, 2016
8aae7f2
Create impls and tests for future-based deduction
sdboyer Aug 14, 2016
0f0690f
Convert old version list test to source-getting
sdboyer Aug 15, 2016
319a07e
Rename remote*.go to deduce*.go
sdboyer Aug 15, 2016
bc1bae3
Fix deduction tests wrt bitbucket reordering
sdboyer Aug 15, 2016
1006147
Remove project_manager.go entirely; tests passing
sdboyer Aug 15, 2016
264cd82
Add DeduceProjectRoot() to SourceManager
sdboyer Aug 15, 2016
185880b
Remove remoteRepo and all related crufty code
sdboyer Aug 15, 2016
4e1f643
hg should already be available on appveyor
sdboyer Aug 15, 2016
cdd194e
Fix waitgroup race conditions in tests
sdboyer Aug 15, 2016
ec580d9
Fix gopkg.in deducer implementation
sdboyer Aug 16, 2016
92406ea
Remove a truckload of dead code
sdboyer Aug 16, 2016
5d88145
Populate baseVCSSource.lvfunc
sdboyer Aug 16, 2016
8fea824
Vanity import deduction tests
sdboyer Aug 16, 2016
cff2ef6
Flesh out the source testing a little more
sdboyer Aug 16, 2016
737841a
More crufty code removal
sdboyer Aug 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ There are also some current non-choices that we would like to push into the real

* Different versions of packages from the same repository cannot be used
* Importable projects that are not bound to the repository root
* Source inference around different import path patterns (e.g., how `github.com/*` or `my_company/*` are handled)

### Choices

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ platform:
install:
- go version
- go env
- choco install bzr hg
- choco install bzr
- set PATH=C:\Program Files (x86)\Bazaar\;C:\Program Files\Mercurial\;%PATH%
build_script:
- go get github.com/Masterminds/glide
Expand Down
79 changes: 27 additions & 52 deletions bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,20 @@ import (
// sourceBridges provide an adapter to SourceManagers that tailor operations
// for a single solve run.
type sourceBridge interface {
getManifestAndLock(pa atom) (Manifest, Lock, error)
listVersions(id ProjectIdentifier) ([]Version, error)
listPackages(id ProjectIdentifier, v Version) (PackageTree, error)
SourceManager // composes SourceManager
verifyRootDir(path string) error
computeRootReach() ([]string, error)
revisionPresentIn(id ProjectIdentifier, r Revision) (bool, error)
pairRevision(id ProjectIdentifier, r Revision) []Version
pairVersion(id ProjectIdentifier, v UnpairedVersion) PairedVersion
repoExists(id ProjectIdentifier) (bool, error)
vendorCodeExists(id ProjectIdentifier) (bool, error)
matches(id ProjectIdentifier, c Constraint, v Version) bool
matchesAny(id ProjectIdentifier, c1, c2 Constraint) bool
intersect(id ProjectIdentifier, c1, c2 Constraint) Constraint
verifyRootDir(path string) error
analyzerInfo() (string, *semver.Version)
deduceRemoteRepo(path string) (*remoteRepo, error)
}

// bridge is an adapter around a proper SourceManager. It provides localized
// caching that's tailored to the requirements of a particular solve run.
//
// It also performs transformations between ProjectIdentifiers, which is what
// the solver primarily deals in, and ProjectRoot, which is what the
// SourceManager primarily deals in. This separation is helpful because it keeps
// the complexities of deciding what a particular name "means" entirely within
// the solver, while the SourceManager can traffic exclusively in
// globally-unique network names.
//
// Finally, it provides authoritative version/constraint operations, ensuring
// that any possible approach to a match - even those not literally encoded in
// the inputs - is achieved.
Expand All @@ -63,7 +50,7 @@ type bridge struct {
// layered on top of the proper SourceManager's cache; the only difference
// is that this keeps the versions sorted in the direction required by the
// current solve run
vlists map[ProjectRoot][]Version
vlists map[ProjectIdentifier][]Version
}

// Global factory func to create a bridge. This exists solely to allow tests to
Expand All @@ -72,38 +59,27 @@ var mkBridge func(*solver, SourceManager) sourceBridge = func(s *solver, sm Sour
return &bridge{
sm: sm,
s: s,
vlists: make(map[ProjectRoot][]Version),
vlists: make(map[ProjectIdentifier][]Version),
}
}

func (b *bridge) getManifestAndLock(pa atom) (Manifest, Lock, error) {
if pa.id.ProjectRoot == b.s.params.ImportRoot {
func (b *bridge) GetManifestAndLock(id ProjectIdentifier, v Version) (Manifest, Lock, error) {
if id.ProjectRoot == b.s.params.ImportRoot {
return b.s.rm, b.s.rl, nil
}
return b.sm.GetManifestAndLock(ProjectRoot(pa.id.netName()), pa.v)
return b.sm.GetManifestAndLock(id, v)
}

func (b *bridge) analyzerInfo() (string, *semver.Version) {
func (b *bridge) AnalyzerInfo() (string, *semver.Version) {
return b.sm.AnalyzerInfo()
}

func (b *bridge) key(id ProjectIdentifier) ProjectRoot {
k := ProjectRoot(id.NetworkName)
if k == "" {
k = id.ProjectRoot
}

return k
}

func (b *bridge) listVersions(id ProjectIdentifier) ([]Version, error) {
k := b.key(id)

if vl, exists := b.vlists[k]; exists {
func (b *bridge) ListVersions(id ProjectIdentifier) ([]Version, error) {
if vl, exists := b.vlists[id]; exists {
return vl, nil
}

vl, err := b.sm.ListVersions(k)
vl, err := b.sm.ListVersions(id)
// TODO(sdboyer) cache errors, too?
if err != nil {
return nil, err
Expand All @@ -115,18 +91,16 @@ func (b *bridge) listVersions(id ProjectIdentifier) ([]Version, error) {
sort.Sort(upgradeVersionSorter(vl))
}

b.vlists[k] = vl
b.vlists[id] = vl
return vl, nil
}

func (b *bridge) revisionPresentIn(id ProjectIdentifier, r Revision) (bool, error) {
k := b.key(id)
return b.sm.RevisionPresentIn(k, r)
func (b *bridge) RevisionPresentIn(id ProjectIdentifier, r Revision) (bool, error) {
return b.sm.RevisionPresentIn(id, r)
}

func (b *bridge) repoExists(id ProjectIdentifier) (bool, error) {
k := b.key(id)
return b.sm.RepoExists(k)
func (b *bridge) SourceExists(id ProjectIdentifier) (bool, error) {
return b.sm.SourceExists(id)
}

func (b *bridge) vendorCodeExists(id ProjectIdentifier) (bool, error) {
Expand All @@ -141,7 +115,7 @@ func (b *bridge) vendorCodeExists(id ProjectIdentifier) (bool, error) {
}

func (b *bridge) pairVersion(id ProjectIdentifier, v UnpairedVersion) PairedVersion {
vl, err := b.listVersions(id)
vl, err := b.ListVersions(id)
if err != nil {
return nil
}
Expand All @@ -159,7 +133,7 @@ func (b *bridge) pairVersion(id ProjectIdentifier, v UnpairedVersion) PairedVers
}

func (b *bridge) pairRevision(id ProjectIdentifier, r Revision) []Version {
vl, err := b.listVersions(id)
vl, err := b.ListVersions(id)
if err != nil {
return nil
}
Expand Down Expand Up @@ -409,14 +383,17 @@ func (b *bridge) listRootPackages() (PackageTree, error) {
//
// The root project is handled separately, as the source manager isn't
// responsible for that code.
func (b *bridge) listPackages(id ProjectIdentifier, v Version) (PackageTree, error) {
func (b *bridge) ListPackages(id ProjectIdentifier, v Version) (PackageTree, error) {
if id.ProjectRoot == b.s.params.ImportRoot {
return b.listRootPackages()
}

// FIXME if we're aliasing here, the returned PackageTree will have
// unaliased import paths, which is super not correct
return b.sm.ListPackages(b.key(id), v)
return b.sm.ListPackages(id, v)
}

func (b *bridge) ExportProject(id ProjectIdentifier, v Version, path string) error {
//return b.sm.ExportProject(id, v, path)
panic("bridge should never be used to ExportProject")
}

// verifyRoot ensures that the provided path to the project root is in good
Expand All @@ -432,10 +409,8 @@ func (b *bridge) verifyRootDir(path string) error {
return nil
}

// deduceRemoteRepo deduces certain network-oriented properties about an import
// path.
func (b *bridge) deduceRemoteRepo(path string) (*remoteRepo, error) {
return deduceRemoteRepo(path)
func (b *bridge) DeduceProjectRoot(ip string) (ProjectRoot, error) {
return b.sm.DeduceProjectRoot(ip)
}

// versionTypeUnion represents a set of versions that are, within the scope of
Expand Down
Loading