Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 6211c75

Browse files
authored
Merge pull request #1884 from sdboyer/discard-version-unifier
gps: Remove versionTypeUnion
2 parents 684854d + c9551ea commit 6211c75

File tree

15 files changed

+21
-721
lines changed

15 files changed

+21
-721
lines changed

cmd/dep/testdata/harness_tests/ensure/add/desync/final/Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/ensure/empty/case2/final/Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/ensure/pkg-ignored/wildcard-ignore/final/Gopkg.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/ensure/update/case1/final/Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/ensure/update/desync/final/Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/dep/testdata/harness_tests/init/gvt/case1/initial/vendor/manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"importpath": "github.com/sdboyer/deptestdos",
1212
"repository": "https://github.com/sdboyer/deptestdos",
13-
"revision": "5c607206be5decd28e6263ffffdcee067266015eXXX",
13+
"revision": "5c607206be5decd28e6263ffffdcee067266015e",
1414
"branch": "master"
1515
},
1616
{

gps/constraint.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ func (c semverConstraint) typedString() string {
169169

170170
func (c semverConstraint) Matches(v Version) bool {
171171
switch tv := v.(type) {
172-
case versionTypeUnion:
173-
for _, elem := range tv {
174-
if c.Matches(elem) {
175-
return true
176-
}
177-
}
178172
case semVersion:
179173
return c.c.Matches(tv.sv) == nil
180174
case versionPair:
@@ -194,12 +188,6 @@ func (c semverConstraint) Intersect(c2 Constraint) Constraint {
194188
switch tc := c2.(type) {
195189
case anyConstraint:
196190
return c
197-
case versionTypeUnion:
198-
for _, elem := range tc {
199-
if rc := c.Intersect(elem); rc != none {
200-
return rc
201-
}
202-
}
203191
case semverConstraint:
204192
rc := c.c.Intersect(tc.c)
205193
if !semver.IsNone(rc) {

gps/constraint_test.go

Lines changed: 0 additions & 179 deletions
Original file line numberDiff line numberDiff line change
@@ -697,183 +697,6 @@ func TestSemverConstraint_ImpliedCaret(t *testing.T) {
697697
}
698698
}
699699

700-
// Test that certain types of cross-version comparisons work when they are
701-
// expressed as a version union (but that others don't).
702-
func TestVersionUnion(t *testing.T) {
703-
rev := Revision("flooboofoobooo")
704-
v1 := NewBranch("master")
705-
v2 := NewBranch("test")
706-
v3 := NewVersion("1.0.0").Pair(rev)
707-
v4 := NewVersion("1.0.1")
708-
v5 := NewVersion("v2.0.5").Pair(Revision("notamatch"))
709-
710-
uv1 := versionTypeUnion{v1, v4, rev}
711-
uv2 := versionTypeUnion{v2, v3}
712-
713-
if uv1.MatchesAny(none) {
714-
t.Errorf("Union can't match none")
715-
}
716-
if none.MatchesAny(uv1) {
717-
t.Errorf("Union can't match none")
718-
}
719-
720-
if !uv1.MatchesAny(any) {
721-
t.Errorf("Union must match any")
722-
}
723-
if !any.MatchesAny(uv1) {
724-
t.Errorf("Union must match any")
725-
}
726-
727-
// Basic matching
728-
if !uv1.Matches(v4) {
729-
t.Errorf("Union should match on branch to branch")
730-
}
731-
if !v4.Matches(uv1) {
732-
t.Errorf("Union should reverse-match on branch to branch")
733-
}
734-
735-
if !uv1.Matches(v3) {
736-
t.Errorf("Union should match on rev to paired rev")
737-
}
738-
if !v3.Matches(uv1) {
739-
t.Errorf("Union should reverse-match on rev to paired rev")
740-
}
741-
742-
if uv1.Matches(v2) {
743-
t.Errorf("Union should not match on anything in disjoint unpaired")
744-
}
745-
if v2.Matches(uv1) {
746-
t.Errorf("Union should not reverse-match on anything in disjoint unpaired")
747-
}
748-
749-
if uv1.Matches(v5) {
750-
t.Errorf("Union should not match on anything in disjoint pair")
751-
}
752-
if v5.Matches(uv1) {
753-
t.Errorf("Union should not reverse-match on anything in disjoint pair")
754-
}
755-
756-
if !uv1.Matches(uv2) {
757-
t.Errorf("Union should succeed on matching comparison to other union with some overlap")
758-
}
759-
760-
// MatchesAny - repeat Matches for safety, but add more, too
761-
if !uv1.MatchesAny(v4) {
762-
t.Errorf("Union should match on branch to branch")
763-
}
764-
if !v4.MatchesAny(uv1) {
765-
t.Errorf("Union should reverse-match on branch to branch")
766-
}
767-
768-
if !uv1.MatchesAny(v3) {
769-
t.Errorf("Union should match on rev to paired rev")
770-
}
771-
if !v3.MatchesAny(uv1) {
772-
t.Errorf("Union should reverse-match on rev to paired rev")
773-
}
774-
775-
if uv1.MatchesAny(v2) {
776-
t.Errorf("Union should not match on anything in disjoint unpaired")
777-
}
778-
if v2.MatchesAny(uv1) {
779-
t.Errorf("Union should not reverse-match on anything in disjoint unpaired")
780-
}
781-
782-
if uv1.MatchesAny(v5) {
783-
t.Errorf("Union should not match on anything in disjoint pair")
784-
}
785-
if v5.MatchesAny(uv1) {
786-
t.Errorf("Union should not reverse-match on anything in disjoint pair")
787-
}
788-
789-
c1, _ := NewSemverConstraint("~1.0.0")
790-
c2, _ := NewSemverConstraint("~2.0.0")
791-
if !uv1.MatchesAny(c1) {
792-
t.Errorf("Union should have some overlap due to containing 1.0.1 version")
793-
}
794-
if !c1.MatchesAny(uv1) {
795-
t.Errorf("Union should have some overlap due to containing 1.0.1 version")
796-
}
797-
798-
if uv1.MatchesAny(c2) {
799-
t.Errorf("Union should have no overlap with ~2.0.0 semver range")
800-
}
801-
if c2.MatchesAny(uv1) {
802-
t.Errorf("Union should have no overlap with ~2.0.0 semver range")
803-
}
804-
805-
if !uv1.MatchesAny(uv2) {
806-
t.Errorf("Union should succeed on MatchAny against other union with some overlap")
807-
}
808-
809-
// Intersect - repeat all previous
810-
if uv1.Intersect(v4) != v4 {
811-
t.Errorf("Union intersection on contained version should return that version")
812-
}
813-
if v4.Intersect(uv1) != v4 {
814-
t.Errorf("Union reverse-intersection on contained version should return that version")
815-
}
816-
817-
if uv1.Intersect(v3) != rev {
818-
t.Errorf("Union intersection on paired version w/matching rev should return rev, got %s", uv1.Intersect(v3))
819-
}
820-
if v3.Intersect(uv1) != rev {
821-
t.Errorf("Union reverse-intersection on paired version w/matching rev should return rev, got %s", v3.Intersect(uv1))
822-
}
823-
824-
if uv1.Intersect(v2) != none {
825-
t.Errorf("Union should not intersect with anything in disjoint unpaired")
826-
}
827-
if v2.Intersect(uv1) != none {
828-
t.Errorf("Union should not reverse-intersect with anything in disjoint unpaired")
829-
}
830-
831-
if uv1.Intersect(v5) != none {
832-
t.Errorf("Union should not intersect with anything in disjoint pair")
833-
}
834-
if v5.Intersect(uv1) != none {
835-
t.Errorf("Union should not reverse-intersect with anything in disjoint pair")
836-
}
837-
838-
if uv1.Intersect(c1) != v4 {
839-
t.Errorf("Union intersecting with semver range should return 1.0.1 version, got %s", uv1.Intersect(c1))
840-
}
841-
if c1.Intersect(uv1) != v4 {
842-
t.Errorf("Union reverse-intersecting with semver range should return 1.0.1 version, got %s", c1.Intersect(uv1))
843-
}
844-
845-
if uv1.Intersect(c2) != none {
846-
t.Errorf("Union intersecting with non-overlapping semver range should return none, got %s", uv1.Intersect(c2))
847-
}
848-
if c2.Intersect(uv1) != none {
849-
t.Errorf("Union reverse-intersecting with non-overlapping semver range should return none, got %s", uv1.Intersect(c2))
850-
}
851-
852-
if uv1.Intersect(uv2) != rev {
853-
t.Errorf("Unions should intersect down to rev, but got %s", uv1.Intersect(uv2))
854-
}
855-
}
856-
857-
func TestVersionUnionPanicOnType(t *testing.T) {
858-
// versionTypeUnions need to panic if Type() gets called
859-
defer func() {
860-
if err := recover(); err == nil {
861-
t.Error("versionTypeUnion did not panic on Type() call")
862-
}
863-
}()
864-
_ = versionTypeUnion{}.Type()
865-
}
866-
867-
func TestVersionUnionPanicOnString(t *testing.T) {
868-
// versionStringUnions need to panic if String() gets called
869-
defer func() {
870-
if err := recover(); err == nil {
871-
t.Error("versionStringUnion did not panic on String() call")
872-
}
873-
}()
874-
_ = versionTypeUnion{}.String()
875-
}
876-
877700
func TestTypedConstraintString(t *testing.T) {
878701
// Also tests typedVersionString(), as this nests down into that
879702
rev := Revision("flooboofoobooo")
@@ -944,8 +767,6 @@ func TestConstraintsIdentical(t *testing.T) {
944767
{Revision("test"), Revision("test"), true},
945768
{Revision("test"), Revision("test2"), false},
946769
{testSemverConstraint(t, "v2.10.7"), testSemverConstraint(t, "v2.10.7"), true},
947-
{versionTypeUnion{NewVersion("test"), NewBranch("branch")},
948-
versionTypeUnion{NewBranch("branch"), NewVersion("test")}, true},
949770
} {
950771
if test.eq != test.a.identical(test.b) {
951772
want := "identical"

gps/satisfy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ func (s *solver) check(a atomWithPackages, pkgonly bool) error {
8080
// the constraints established by the current solution.
8181
func (s *solver) checkAtomAllowable(pa atom) error {
8282
constraint := s.sel.getConstraint(pa.id)
83-
if s.vUnify.matches(pa.id, constraint, pa.v) {
83+
if constraint.Matches(pa.v) {
8484
return nil
8585
}
8686
// TODO(sdboyer) collect constraint failure reason (wait...aren't we, below?)
8787

8888
deps := s.sel.getDependenciesOn(pa.id)
8989
var failparent []dependency
9090
for _, dep := range deps {
91-
if !s.vUnify.matches(pa.id, dep.dep.Constraint, pa.v) {
91+
if !dep.dep.Constraint.Matches(pa.v) {
9292
s.fail(dep.depender.id)
9393
failparent = append(failparent, dep)
9494
}
@@ -150,7 +150,7 @@ func (s *solver) checkDepsConstraintsAllowable(a atomWithPackages, cdep complete
150150
constraint := s.sel.getConstraint(dep.Ident)
151151
// Ensure the constraint expressed by the dep has at least some possible
152152
// intersection with the intersection of existing constraints.
153-
if s.vUnify.matchesAny(dep.Ident, constraint, dep.Constraint) {
153+
if constraint.MatchesAny(dep.Constraint) {
154154
return nil
155155
}
156156

@@ -159,7 +159,7 @@ func (s *solver) checkDepsConstraintsAllowable(a atomWithPackages, cdep complete
159159
var failsib []dependency
160160
var nofailsib []dependency
161161
for _, sibling := range siblings {
162-
if !s.vUnify.matchesAny(dep.Ident, sibling.dep.Constraint, dep.Constraint) {
162+
if !sibling.dep.Constraint.MatchesAny(dep.Constraint) {
163163
s.fail(sibling.depender.id)
164164
failsib = append(failsib, sibling)
165165
} else {
@@ -181,7 +181,7 @@ func (s *solver) checkDepsConstraintsAllowable(a atomWithPackages, cdep complete
181181
func (s *solver) checkDepsDisallowsSelected(a atomWithPackages, cdep completeDep) error {
182182
dep := cdep.workingConstraint
183183
selected, exists := s.sel.selected(dep.Ident)
184-
if exists && !s.vUnify.matches(dep.Ident, dep.Constraint, selected.a.v) {
184+
if exists && !dep.Constraint.Matches(selected.a.v) {
185185
s.fail(dep.Ident)
186186

187187
return &constraintNotAllowedFailure{

gps/selection.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ type selection struct {
1616
// ProjectRoots to the particular case variant that has currently been
1717
// selected.
1818
foldRoots map[string]ProjectRoot
19-
// The versoinUnifier in use for this solve run.
20-
vu *versionUnifier
2119
}
2220

2321
type selected struct {
@@ -159,7 +157,7 @@ func (s *selection) getConstraint(id ProjectIdentifier) Constraint {
159157
// Start with the open set
160158
var ret Constraint = any
161159
for _, dep := range deps {
162-
ret = s.vu.intersect(id, ret, dep.dep.Constraint)
160+
ret = ret.Intersect(dep.dep.Constraint)
163161
}
164162

165163
return ret

gps/solve_basic_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@ var basicFixtures = map[string]basicFixture{
847847
"foo 1.0.1 foorev", // mkrevlock drops the 1.0.1
848848
),
849849
r: mksolution(
850-
"foo 1.0.1 foorev",
851-
"bar 1.0.1",
850+
"foo 1.0.2",
851+
"bar 1.0.2",
852852
),
853853
},
854854
"lock to branch on old rev keeps old rev": {

0 commit comments

Comments
 (0)