Design 47 H1 (2): a take-in again keeps the trunk's next catalog revision of the same source
The take-in again keeps what it recomputed as a re-pin does: the trunk's next revision of the newest's source, its call 'take-in again of <repository>', its movers every module whose fingerprint moved, pinned for its pipeline, said as catalog-revision. Builds: design 47 H-A-208, H-A-210 as H-A-211 and H-A-212 amend it, H-A-213 (1), (3)
This commit is contained in:
@@ -15,10 +15,14 @@ import (
|
||||
// take-in (such as the walk of the module graph, H-A-201) reaches a repository with no merge since.
|
||||
const TakeInAgainTool = "indexer_take_in_again"
|
||||
|
||||
// TakeInAgainCall is the call of the catalog revision a take-in again keeps (design 47 H-A-212, H-A-213 (3)).
|
||||
func TakeInAgainCall(repository string) string { return "take-in again of " + repository }
|
||||
|
||||
// TakeInAgain re-reads the repository's module graph at the merge commit its taken key keeps (wholeAt, the reading of every
|
||||
// take-in: the kept requirements of each of its modules, H-A-201, H-A-157) and applies it as a take-in does, whose recompute
|
||||
// of the modules state is the one a publish re-pin runs (recomputeLocked): pins and fingerprints move as they would there.
|
||||
// It keeps no catalog revision and asks no gate (H-A-210). A repository with no taken key is refused, said in the answer.
|
||||
// It keeps the result as the trunk's next catalog revision of the same source, its call TakeInAgainCall (H-A-212, H-A-213),
|
||||
// and asks no gate. A repository with no taken key is refused, said in the answer.
|
||||
func (ix *Indexer) TakeInAgain(ctx context.Context, repository string) TakenIn {
|
||||
repository = strings.TrimSpace(repository)
|
||||
r := TakenIn{Module: repository, Repository: repository}
|
||||
@@ -59,6 +63,11 @@ func (ix *Indexer) TakeInAgain(ctx context.Context, repository string) TakenIn {
|
||||
if err != nil {
|
||||
return refuse("taking %s at %.12s in again: %v", repository, t.Merge, err)
|
||||
}
|
||||
// The take-in again keeps its revision as a re-pin does: the branch's next, of the same source, its call naming the
|
||||
// repository, its movers every module whose fingerprint moved (design 47 H-A-212, H-A-213).
|
||||
if err := ix.keepRepinned(ctx, ix, TrunkBranch, TakeInAgainCall(repository), nil); err != nil {
|
||||
return refuse("taken in again at %.12s, but its catalog revision is not kept: %v", t.Merge, err)
|
||||
}
|
||||
r.Stored, r.Commit = true, t.Merge
|
||||
r.Answer = fmt.Sprintf("taken in again at %.12s: %d modules written", t.Merge, len(applied.Written))
|
||||
if len(applied.Written) > 0 {
|
||||
|
||||
@@ -7,17 +7,19 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
// Design 47 H-A-208, H-A-210: a repository taken in before the walk of the module graph (H-A-201) keeps its modules' direct
|
||||
// requirements only; indexer_take_in_again re-reads it at its kept merge commit and recomputes the modules state, so the
|
||||
// module's kept requirements and pins gain the transitive package. An unknown repository is refused.
|
||||
// module's kept requirements and pins gain the transitive package, and keeps the trunk's next catalog revision of the same
|
||||
// source with the call "take-in again of <repository>" (H-A-212, H-A-213). An unknown repository is refused.
|
||||
func TestATakeInAgainReachesARepositoryWithNoMergeSince(t *testing.T) {
|
||||
const conditions = "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
||||
objects := map[string]string{"modules/b/builds": strings.Repeat("b", 40), "modules/c/client": strings.Repeat("c", 40)}
|
||||
ix, mods, _ := ptpIndexer(t, objects)
|
||||
ix.Taken = newMem()
|
||||
ix.Taken, ix.Revisions, ix.Packages = newMem(), newMemObjects(1<<20), newMem()
|
||||
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1")
|
||||
direct := map[string]string{"modules/g": "module g\n\nrequire git.novox.be/novox/mesh-delivery/modules/b/builds" + ptpZero + "\n"}
|
||||
walked := map[string]string{"modules/c/client": "module git.novox.be/novox/mesh-delivery/modules/c/client\n\nrequire " + conditions + ptpZero + "\n"}
|
||||
@@ -39,11 +41,29 @@ func TestATakeInAgainReachesARepositoryWithNoMergeSince(t *testing.T) {
|
||||
return RepoRead{Root: f.Root, Trees: f.Trees, Manifests: f.Manifests, Locks: f.Locks, Packages: f.Packages}, nil
|
||||
}
|
||||
ctx := context.Background()
|
||||
for p, v := range map[string]string{conditions: "0.1.4", "git.novox.be/novox/mesh-sdk/go": "0.1.27"} {
|
||||
if _, err := ix.HearVersion(ctx, HeardVersion{Package: p, GoModule: p, Version: v, Published: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// the modules that hold the two packages, so their published versions pin them (fingerprint.HolderOf)
|
||||
mods.put("mesh-sdk", mustEncode(t, meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-sdk", Commit: strings.Repeat("1", 40),
|
||||
Path: meshcatalogclient.RootPath, None2: None2Pending}))
|
||||
mods.put("meshconditionsclient", mustEncode(t, meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-contracts", Commit: strings.Repeat("2", 40),
|
||||
Path: "health-and-repair/go/clients/meshconditionsclient", None2: None2Pending}))
|
||||
if err := ix.Apply(ctx, f); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if m, _ := moduleOf(t, mods, "g"); m.Inputs2 == nil || slices.Contains(m.Inputs2.Packages, conditions) || strings.Contains(m.None2, conditions) {
|
||||
t.Fatalf("before: packages = %+v (%s), want no transitive requirement yet", m.Inputs2, m.None2)
|
||||
before, _ := moduleOf(t, mods, "g")
|
||||
if before.Inputs2 == nil || slices.Contains(before.Inputs2.Packages, conditions) || strings.Contains(before.None2, conditions) {
|
||||
t.Fatalf("before: packages = %+v (%s), want no transitive requirement yet", before.Inputs2, before.None2)
|
||||
}
|
||||
entries, err := ix.viewEntries(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ix.KeepBranchEntries(ctx, TrunkBranch, 4, entries, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if r := ix.TakeInAgain(ctx, "novox/unknown"); r.Stored || !strings.HasPrefix(r.Answer, "refused:") {
|
||||
t.Errorf("unknown repository: %+v, want refused", r)
|
||||
@@ -61,12 +81,14 @@ func TestATakeInAgainReachesARepositoryWithNoMergeSince(t *testing.T) {
|
||||
if m.Inputs2 == nil || !slices.Contains(m.Inputs2.Packages, conditions) {
|
||||
t.Errorf("after: kept requirements = %+v, want %s", m.Inputs2, conditions)
|
||||
}
|
||||
// The recompute pins it: nothing is published here, so the fingerprint waits on it by name (H-A-161), and the pins the
|
||||
// entry names from the kept requirements hold it with no version until it is (H-A-204).
|
||||
if !strings.Contains(m.None2, conditions) {
|
||||
t.Errorf("after: the recompute's reason %q, want it waiting on %s", m.None2, conditions)
|
||||
// The recompute pins it at its published version, which moves the fingerprint (H-A-167, H-A-204), and the take-in again
|
||||
// keeps the trunk's next revision of the same source, its call naming the repository, g its mover (H-A-212, H-A-213).
|
||||
if m.Fp2 == "" || m.Fp2 == before.Fp2 || m.Packages[conditions] != "v0.1.4" {
|
||||
t.Errorf("after: g = %s (%s) pinned %v, want a new fingerprint pinned to v0.1.4 (was %s)", m.Fp2, m.None2, m.Packages, before.Fp2)
|
||||
}
|
||||
if v, named := releasedPins(nil, nil, catalogue.Manifest{}, "novox/mesh-delivery", m.Inputs2.Packages)[conditions]; !named || v != "" {
|
||||
t.Errorf("after: pins name %s %v (%q), want it named, waiting", conditions, named, v)
|
||||
rev, _, found, err := readNewestOf(ctx, ix.Revisions, TrunkBranch)
|
||||
if err != nil || !found || rev.Revision != 2 || rev.Source != 4 || rev.Call != "take-in again of novox/mesh-delivery" ||
|
||||
len(rev.Movers) != 1 || rev.Movers[0].Module != "g" || rev.Movers[0].Fingerprint != m.Fp2 {
|
||||
t.Errorf("the newest trunk revision = %+v (%v), want revision 2 of source 4 with the take-in again's call and g its mover", rev, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,9 +677,9 @@ func (ix *Indexer) repinned(ctx context.Context, module string) (map[string]bool
|
||||
return only, nil
|
||||
}
|
||||
|
||||
// keepRepinned keeps x's view, re-pinned for the modules only names, as branch's next catalog revision of the source of its
|
||||
// newest, with call, when a fingerprint of them moved against that newest; its movers are those that moved (H-A-211,
|
||||
// H-A-212, H-A-213). A branch with no revision kept yet keeps none: there is no source to keep it of.
|
||||
// keepRepinned keeps x's view, re-pinned for the modules only names (every module for nil), as branch's next catalog revision
|
||||
// of the source of its newest, with call, when a fingerprint of them moved against that newest; its movers are those that
|
||||
// moved (H-A-211, H-A-212, H-A-213). A branch with no revision kept yet keeps none: there is no source to keep it of.
|
||||
func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch, call string, only map[string]bool) error {
|
||||
if ix.Revisions == nil {
|
||||
return nil
|
||||
@@ -701,7 +701,11 @@ func (ix *Indexer) keepRepinned(ctx context.Context, x *Indexer, branch, call st
|
||||
was[e.Module] = e.Fp
|
||||
}
|
||||
var movers []meshcatalog.TakeInEntry
|
||||
for _, key := range slices.Sorted(maps.Keys(only)) {
|
||||
moved := slices.Sorted(maps.Keys(only))
|
||||
if only == nil { // a take-in again: every module whose fingerprint moved (H-A-212)
|
||||
moved = slices.Sorted(maps.Keys(entries))
|
||||
}
|
||||
for _, key := range moved {
|
||||
e, ok := entries[key]
|
||||
if !ok || e.Fp == "" || was[e.Module] == e.Fp {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user