Artifact 9496044142037f4e5db6b9da589625be6b321ff7419dfe0753f6511f8bf1f177:
- File
internal/verify/rebuild_leaves.go
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1176) [annotate] [blame] [check-ins using]
package verify import ( "fmt" "github.com/danmestas/libfossil/db" ) // rebuildLeaves populates the leaf table from event/plink data. // A leaf is a checkin that is not a parent of any other checkin. func rebuildLeaves(tx *db.Tx) error { if tx == nil { panic("rebuildLeaves: nil *db.Tx") } _, err := tx.Exec(` INSERT INTO leaf(rid) SELECT e.objid FROM event e WHERE e.type = 'ci' AND NOT EXISTS (SELECT 1 FROM plink WHERE pid = e.objid) `) if err != nil { return fmt.Errorf("rebuildLeaves: %w", err) } return nil } // rebuildBookkeeping populates unclustered and unsent tables. // Every non-phantom blob is marked as unclustered and unsent to // ensure sync will re-evaluate what needs to be pushed. func rebuildBookkeeping(tx *db.Tx) error { if tx == nil { panic("rebuildBookkeeping: nil *db.Tx") } if _, err := tx.Exec("INSERT INTO unclustered(rid) SELECT rid FROM blob WHERE size >= 0"); err != nil { return fmt.Errorf("rebuildBookkeeping unclustered: %w", err) } if _, err := tx.Exec("INSERT INTO unsent(rid) SELECT rid FROM blob WHERE size >= 0"); err != nil { return fmt.Errorf("rebuildBookkeeping unsent: %w", err) } return nil }