delivery: a turn never holds the check of heads that wait in it, so two approved merges in one turn never hold each other's carry (ADR 0548 §3; issue 568, review round 1)
This commit is contained in:
@@ -202,9 +202,9 @@ func TestGateValuesRoundTrip(t *testing.T) { // 1201/AC4
|
||||
t.Errorf("the turn lacks %s: %s", field, data)
|
||||
}
|
||||
}
|
||||
// ADR 0548 §3: a turn holds off every check but the one of a waiting delivery's own heads.
|
||||
if !TurnHolds(tu, "fedcba987654") || TurnHolds(Turn{Waiting: tu.Waiting[:1]}, tu.Waiting[0].Heads) || !TurnHolds(tu, tu.Waiting[0].Heads) {
|
||||
t.Error("TurnHolds: a turn holds other heads' checks and never its only delivery's own")
|
||||
// ADR 0548 §3: a turn holds off every check but those of the heads that wait in it, whoever else waits there.
|
||||
if !TurnHolds(tu, "fedcba987654") || TurnHolds(tu, tu.Waiting[0].Heads) || TurnHolds(tu, tu.Waiting[1].Heads) || TurnHolds(Turn{}, "fedcba987654") {
|
||||
t.Error("TurnHolds: a turn holds other heads' checks and never the check of heads waiting in it")
|
||||
}
|
||||
for name, dec := range map[string]func([]byte) error{
|
||||
"turn": func(b []byte) error { _, err := DecodeTurn(b); return err },
|
||||
|
||||
@@ -117,15 +117,19 @@ func (t Turn) check() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TurnHolds says whether a turn holds off the check of the heads: it names a delivery of other heads. The check of a waiting
|
||||
// delivery's own heads (the carry its merge waits for) is never held by its own turn.
|
||||
// TurnHolds says whether a turn holds off the check of the heads: it names deliveries, and none of them of these heads. A
|
||||
// turn never holds the check of heads that wait in it (the carry a waiting merge needs): two approved merges in one turn whose
|
||||
// trunk moved would otherwise each hold the other's carry, and neither would ever merge (review of ADR 0548's build, round 1).
|
||||
func TurnHolds(t Turn, heads string) bool {
|
||||
if len(t.Waiting) == 0 {
|
||||
return false
|
||||
}
|
||||
for _, w := range t.Waiting {
|
||||
if w.Heads != heads {
|
||||
return true
|
||||
if w.Heads == heads {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
// EncodeTurn is t as JSON at Version; it refuses a turn with no delivery, a repository that is not lowercase <owner>/<name>,
|
||||
|
||||
Reference in New Issue
Block a user