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

Commit 6810902

Browse files
committed
Allow backjumping over pkg-only selections
There had been a canary panic in this case, but that was just incorrect. It's perfectly legitimate for a project marked for retrying to have induced some pkg-only selections. Fixes #408.
1 parent f291eab commit 6810902

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

gps/solve_bimodal_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,49 @@ var bimodalFixtures = map[string]bimodalFixture{
232232
"c 1.0.0",
233233
),
234234
},
235+
"backjump through pkg-only selection": {
236+
ds: []depspec{
237+
dsp(mkDepspec("root 0.0.0"),
238+
pkg("root", "root/foo"),
239+
pkg("root/foo", "a", "b"),
240+
),
241+
dsp(mkDepspec("a 1.0.0"),
242+
pkg("a", "c"),
243+
),
244+
// Include two versions of b to ensure that a is visited first
245+
dsp(mkDepspec("b 0.9.0", "d ^1.0.0"),
246+
pkg("b", "c/other", "d"),
247+
),
248+
dsp(mkDepspec("b 1.0.0", "d ^1.2.0"),
249+
pkg("b", "c/other", "d"),
250+
),
251+
// Three versions of c so it's last
252+
dsp(mkDepspec("c 1.0.0", "d ^1.0.0"),
253+
pkg("c", "d"),
254+
pkg("c/other"),
255+
),
256+
//dsp(mkDepspec("c 1.0.1", "d 1.0.0"),
257+
//pkg("c", "d"),
258+
//pkg("c/other"),
259+
//),
260+
//dsp(mkDepspec("c 1.0.2", "d 1.0.0"),
261+
//pkg("c", "d"),
262+
//pkg("c/other"),
263+
//),
264+
dsp(mkDepspec("d 1.0.0"),
265+
pkg("d"),
266+
),
267+
dsp(mkDepspec("d 1.1.0"),
268+
pkg("d"),
269+
),
270+
},
271+
r: mksolution(
272+
"a 1.0.0",
273+
"b 0.9.0",
274+
mklp("c 1.0.0", ".", "other"),
275+
"d 1.1.0",
276+
),
277+
},
235278
// Import jump is in a dep subpkg, and points to a transitive dep
236279
"transitive subpkg bm-add": {
237280
ds: []depspec{

gps/solver.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,10 +951,13 @@ func (s *solver) backtrack() bool {
951951
// Grab the last versionQueue off the list of queues
952952
q := s.vqs[len(s.vqs)-1]
953953

954-
// Walk back to the next project
955-
awp, proj := s.unselectLast()
956-
if !proj {
957-
panic("canary - *should* be impossible to have a pkg-only selection here")
954+
// Walk back to the next project. This may entail walking through some
955+
// package-only selections.
956+
var proj bool
957+
var awp atomWithPackages
958+
for !proj {
959+
awp, proj = s.unselectLast()
960+
s.traceBacktrack(awp.bmi(), !proj)
958961
}
959962

960963
if !q.id.eq(awp.a.id) {

0 commit comments

Comments
 (0)