Artifact 658ef7bf6da5d6ae58e03a60d47f5574411f3983637314a375698f5e307d1a33:
- File
cli/repo_ci.go
— part of check-in
[7ea6fba63f]
at
2026-10-06 15:57:25
on branch trunk
— fix(checkout): merge the way fossil does, and commit merges with their parent (#244) (#252)
The CLI's merge marked a conflict with vfile.chnged=5, which fossil reads as "added by integrate", and recorded no merge-in version or vmerge row, so a merge went unseen and the next commit dropped the merge parent.
Merging now lives in the library as Checkout.Merge and records what fossil records: chnged=2 and mrid for a file taken from the merged-in version, chnged=3 for an added file, a per-file vmerge row for a merged file, and vmerge id 0 for the merge. Conflicts use fossil's markers and are found by looking for them (Checkout.Conflicts), so fossil and go-libfossil read each other's merges. Where fossil relies on its undo copy, Merge keeps the file or refuses instead.
Commit reads vmerge for merge parents, and, as fossil's commit does, refuses unresolved conflict markers, empty commits, unknown names and partial commits of a merge. The CLI's merge, conflicts, mark-resolved and ci commands call the library; ci now commits the checkout. (user: [email protected], size: 1663) [annotate] [blame] [check-ins using]
package cli import ( "fmt" "path/filepath" libfossil "github.com/danmestas/go-libfossil" ) // RepoCiCmd commits the checkout's changes, as fossil's commit command does: // every change, or only the named files. A pending merge is committed with // the merged-in checkin as a merge parent. type RepoCiCmd struct { Message string `short:"m" required:"" help:"Checkin comment"` Files []string `arg:"" optional:"" help:"Files to commit (default: all changes)"` User string `help:"Checkin user (default: OS username)"` Branch string `help:"Branch name for this checkin"` AllowConflict bool `help:"Commit files that still hold merge conflict markers"` AllowEmpty bool `help:"Commit even when nothing has changed"` Dir string `short:"d" help:"Checkout directory" default:"."` } func (c *RepoCiCmd) Run(g *Globals) (err error) { _, co, done, err := openWorkingCheckout(g, c.Dir) if err != nil { return err } defer closeWith(done, &err) absDir, err := filepath.Abs(c.Dir) if err != nil { return err } files := make([]string, 0, len(c.Files)) for _, path := range c.Files { relPath, err := checkoutRelative(absDir, path) if err != nil { return err } files = append(files, relPath) } user := c.User if user == "" { user = currentUser() } rid, uuid, err := co.Checkin(libfossil.CheckoutCommitOpts{ Message: c.Message, User: user, Branch: c.Branch, Files: files, AllowConflict: c.AllowConflict, AllowEmpty: c.AllowEmpty, }) if err != nil { return err } fmt.Printf("checkin %s (rid=%d)\n", uuid[:10], rid) return nil }