Design 47 H1 (1), review round 1: a source answers its take-in's revision

The revision verb's source input, and the pipeline-wanted that frees pins by it, answer the lowest-numbered revision of a source (the take-in's), never a later re-pin's of the same source. TestIndexerWhole asks the exact first number: the bed seeds main.1 of source 0, so source 10's is 2 (no source is kept twice).

Builds: design 47 H-A-213 (1), (4), H-A-211
This commit is contained in:
2026-11-20 23:39:53 +01:00
parent 1b1fd9a711
commit 83e4470757
3 changed files with 18 additions and 5 deletions
@@ -453,8 +453,8 @@ func TestIndexerWhole(t *testing.T) {
first := heard.next(t, "main", 10)
r := func(source int64) int64 { return first.Revision + source - 10 }
rn := func(source int64) string { return fmt.Sprintf("main.%d", r(source)) }
if len(first.Entries) != 0 || first.Revision <= 0 || first.Source != 10 {
t.Fatalf("the first revision said %+v, want a revision of source 10 with no entries", first)
if len(first.Entries) != 0 || first.Revision != 2 || first.Source != 10 {
t.Fatalf("the first revision said %+v, want revision 2 (the bed's seed is main.1, of source 0) of source 10 with no entries", first)
}
untilKey(t, ctx, pins, index.PinKey("main", r(10)), absent)
@@ -77,6 +77,13 @@ func TestACatalogRevisionIsKeptPerWatchedBranch(t *testing.T) {
if a, err := bySource("feature/x=2ey", 8); err != nil || a.Revision.Revision != 2 {
t.Errorf("the branch's source 8 answered %+v (%v)", a.Revision, err)
}
// H-A-213: a re-pin's revision of source 8 answers below the take-in's: source 8 answers revision 2.
if _, err := ix.keepBranchEntries(ctx, "feature/x.y", 8, "release of mesh-sdk 0.1.27", tip("c4"), nil); err != nil {
t.Fatal(err)
}
if a, err := bySource("feature/x=2ey", 8); err != nil || a.Revision.Revision != 2 || a.Entries[0].Commit != "c3" {
t.Errorf("the branch's source 8 after a re-pin answered %+v (%v), want the take-in's revision 2", a.Revision, err)
}
if _, err := bySource("feature/x=2ey", 9); err == nil {
t.Error("a source no revision was taken in from was answered")
}
@@ -167,18 +167,24 @@ func revisionOfSource(ctx context.Context, o Objects, branch string, source int6
}
}
slices.SortFunc(found, func(a, b int64) int { return int(b - a) })
// A re-pin or a take-in again keeps a later revision of the same source (H-A-211, H-A-213): the source's own revision is
// the lowest numbered of it, the take-in's.
lowest := ""
for _, r := range found {
name := RevisionObject(meshcatalog.CatalogRevision{Branch: branch, Revision: r})
rev, _, err := ReadRevision(ctx, o, name)
if err != nil {
return "", err
}
if rev.Source == source {
return name, nil
}
if rev.Source < source {
break
}
if rev.Source == source {
lowest = name
}
}
if lowest != "" {
return lowest, nil
}
return "", fmt.Errorf("no revision of %q was taken in from the source revision %d", branch, source)
}