Artifact 691859b381a29f03b8b0c9e671f4c4e0702666c6e19f75b51b77c30b2c59f4e9:
- File
repo_submanifest.go
— part of check-in
[5377023003]
at
2026-10-18 17:04:24
on branch feat/submanifest-reader
— feat: select over the main-branch tip, and add submanifests status
Repo.EnableSubmanifests(k) now analyzes the current trunk, the check-in the next commit most plausibly descends from, instead of the newest check-in; with no trunk check-in only an explicit k succeeds. A test puts a newer one-file check-in on another branch to show which one is read. Repo.DisableSubmanifests returns only an error and documents that existing trees stay.
`libfossil repo submanifests status` prints the three settings and whether the repository holds a tree; `retune` requires --k, and `disable` prints zit's note when trees exist. The SDK pages are rebuilt with make docs-gen-sdk. (user: [email protected], size: 2566) [annotate] [blame] [check-ins using]
package libfossil import ( "errors" "fmt" fsltype "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/manifest" ) // EnableSubmanifests turns on tree manifest emission // (draft-fossil-submanifests-00 §8.1): from the next commit, check-ins carry // their file sets as sub-manifest trees. k is the partition parameter, 1 to // 12, or 0 to select one. A valid pinned k is kept, and an explicit k that // differs from it is refused: changing it is RetuneSubmanifests. With no // valid pin, an explicit k is pinned, or one is selected as zit selects it: // the §6.3 cost over the file set of the current trunk (CurrentTrunk, the // main-branch tip, the check-in the next commit most plausibly descends // from), refined by replaying recent history. A request that cannot be met // -- k outside 1..12, no check-in to select from, or a file set no k // partitions -- changes neither setting. It returns the pinned k and the // warning the operator must be shown: peers older than Fossil 2.29 are // refused trees, and trees cannot be retired. func (r *Repo) EnableSubmanifests(k int) (pinned int, warning string, err error) { current, err := r.CurrentTrunk() if errors.Is(err, ErrVersionNotFound) { current, err = 0, nil } if err != nil { return 0, "", fmt.Errorf("libfossil: enable sub-manifests: %w", err) } pinned, err = manifest.EnableSubmanifests(r.inner, fsltype.FslID(current), k) if err != nil { return 0, "", fmt.Errorf("libfossil: enable sub-manifests: %w", err) } return pinned, manifest.SubmanifestEnableWarning, nil } // RetuneSubmanifests pins a new partition parameter k, 1 to 12, for the // commits that follow (draft-fossil-submanifests-00 §6.4). It is forward // only: existing check-ins are unchanged, and the next tree shares only the // sub-manifests whose bytes are the same under both values. func (r *Repo) RetuneSubmanifests(k int) error { if err := manifest.RetuneSubmanifests(r.inner, k); err != nil { return fmt.Errorf("libfossil: re-tune sub-manifests: %w", err) } return nil } // DisableSubmanifests turns tree manifest emission off: later commits are // flat, and the pinned k is kept for a later EnableSubmanifests. Existing // trees are untouched -- artifact names are immutable, so they cannot be // retired -- and peers older than Fossil 2.29 are still refused them. func (r *Repo) DisableSubmanifests() error { if _, err := manifest.DisableSubmanifests(r.inner); err != nil { return fmt.Errorf("libfossil: disable sub-manifests: %w", err) } return nil }