Artifact 3a1e93466073d977180676b3556796a604827135be0985ac466bae19068ddd91:
- File
simio/storage.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: 1556) [annotate] [blame] [check-ins using]
package simio import ( "io/fs" "os" "time" ) // Storage abstracts filesystem operations for WASM portability. type Storage interface { Stat(path string) (os.FileInfo, error) Remove(path string) error MkdirAll(path string, perm os.FileMode) error ReadFile(path string) ([]byte, error) WriteFile(path string, data []byte, perm os.FileMode) error ReadDir(path string) ([]fs.DirEntry, error) Chtimes(path string, atime, mtime time.Time) error } // OSStorage delegates to the os package. Used in production and WASI. type OSStorage struct{} func (OSStorage) Stat(path string) (os.FileInfo, error) { return os.Stat(path) } func (OSStorage) Remove(path string) error { return os.Remove(path) } func (OSStorage) MkdirAll(path string, perm os.FileMode) error { return os.MkdirAll(path, perm) } func (OSStorage) ReadFile(path string) ([]byte, error) { return os.ReadFile(path) } func (OSStorage) WriteFile(path string, data []byte, perm os.FileMode) error { return os.WriteFile(path, data, perm) } func (OSStorage) ReadDir(path string) ([]fs.DirEntry, error) { return os.ReadDir(path) } func (OSStorage) Chtimes(path string, atime, mtime time.Time) error { return os.Chtimes(path, atime, mtime) } // Chmod changes a file's mode. It is not part of Storage, since not every // storage has file modes; callers that need it check for it. func (OSStorage) Chmod(path string, mode os.FileMode) error { return os.Chmod(path, mode) }