aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/mvs/mvs.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2019-07-17 12:53:47 -0400
committerBryan C. Mills <bcmills@google.com>2019-07-18 19:42:57 +0000
commita005f998cd1a364d5d341eb8f185fb6ae5aa62cb (patch)
treebb4bc36d5836350e63be964c91e784991013ae36 /src/cmd/go/internal/mvs/mvs.go
parent4a2d3d06873559df2b6933f260dc8f75c54c9771 (diff)
downloadgo-a005f998cd1a364d5d341eb8f185fb6ae5aa62cb.tar.gz
go-a005f998cd1a364d5d341eb8f185fb6ae5aa62cb.zip
cmd/go/internal/mvs: retain modules required by older versions
Fixes #29773 Updates #31248 Change-Id: Ic1923119c8cf3a60c586df1b270c3af0c9095f29 Reviewed-on: https://go-review.googlesource.com/c/go/+/186537 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/mvs/mvs.go')
-rw-r--r--src/cmd/go/internal/mvs/mvs.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/cmd/go/internal/mvs/mvs.go b/src/cmd/go/internal/mvs/mvs.go
index 568efbd8b2..f9292a05e8 100644
--- a/src/cmd/go/internal/mvs/mvs.go
+++ b/src/cmd/go/internal/mvs/mvs.go
@@ -216,8 +216,8 @@ func buildList(target module.Version, reqs Reqs, upgrade func(module.Version) (m
}
}
- // Construct the list by traversing the graph again, replacing older
- // modules with required minimum versions.
+ // The final list is the minimum version of each module found in the graph.
+
if v := min[target.Path]; v != target.Version {
// TODO(jayconrod): there is a special case in modload.mvsReqs.Max
// that prevents us from selecting a newer version of a module
@@ -228,19 +228,18 @@ func buildList(target module.Version, reqs Reqs, upgrade func(module.Version) (m
}
list := []module.Version{target}
- listed := map[string]bool{target.Path: true}
- for i := 0; i < len(list); i++ {
- n := modGraph[list[i]]
+ for path, vers := range min {
+ if path != target.Path {
+ list = append(list, module.Version{Path: path, Version: vers})
+ }
+
+ n := modGraph[module.Version{Path: path, Version: vers}]
required := n.required
for _, r := range required {
v := min[r.Path]
if r.Path != target.Path && reqs.Max(v, r.Version) != v {
panic(fmt.Sprintf("mistake: version %q does not satisfy requirement %+v", v, r)) // TODO: Don't panic.
}
- if !listed[r.Path] {
- list = append(list, module.Version{Path: r.Path, Version: v})
- listed[r.Path] = true
- }
}
}