Documentation
¶
Overview ¶
Package undo saves, restores, and redoes checkout state in a Fossil .fslckout database.
The undo state machine uses a vvar entry "undo_available":
0 — nothing saved 1 — undo available (Save was called) 2 — redo available (Undo was called)
Only one level of undo/redo is kept; each Save replaces any previous state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RestoreFiles ¶ added in v0.14.0
RestoreFiles puts files back through disk as ReadFile found them, as fossil's undo_rollback does for an operation that failed partway.
func Save ¶
Save snapshots the current checkout state so it can be undone later. If pathnames is non-nil and non-empty, only those vfile entries are saved; otherwise all vfile rows are included. Files are read through disk, as fossil's undo_save reads them: a symlink seen as itself is saved as one.
A saved vfile row keeps its mtime only while it vouches for the saved content, that is while the file's mtime still matches it, so Undo can record a restored file's new mtime on it; otherwise it is saved with 0.
func SaveTx ¶ added in v0.14.0
SaveTx replaces the undo state within tx, as fossil's undo_begin and undo_save do: copies of vfile and vmerge as they are now, files (each pathname once, the first kept), and the checked-out version, with undo marked available. The caller runs it before the operation's own changes to vfile, in the same transaction.
Types ¶
type Change ¶ added in v0.14.0
Change is one working file Undo or Redo changed, for a caller to report as fossil's undo prints it.
func Redo ¶
Redo reverses the most recent Undo, returning the working files it changed as Undo does. It requires undo_available == 2.
func Swap ¶ added in v0.14.0
func Swap( ckout *sql.DB, disk vfile.Disk, dir string, redo bool, hashOf func(int64) (string, error), ) ([]Change, error)
Swap is Undo, or Redo when redo is set, that also keeps vvar's checkout-hash naming the checked-out version, as fossil's db_set_checkout does: hashOf returns the hash of a check-in rid.