Undo and recover

Undo and recover

Every command that changes your view records one operation: which change the working tree sits on, the working change, the heads and any open conflicts. loot undo steps back one operation, loot op restore <n> jumps to any, and each records a new operation, so nothing is deleted and a redo always has somewhere to land.

Step back from a finalize

$ loot describe -m "move to 9090"
$ loot new
finalized working change 008f6887; started fresh change vnmqzmko
$ loot undo
undid op 4 (new) — now at op 3, head 008f6887
  working change 008f6887
$ loot status
working change pyqwuovo  008f6887  "move to 9090"
  M  app.conf               internal

The change is unsigned again and your edit is back in the working change. The signed version stays in the store, and loot op restore 4 returns to it.

An undo lands on the operation before, not on your edits. If you finalized with loot new -m and no describe, the operation before predates your edits, so the undo shows the previous change; restore the finalize to get them back. To change a finalized tip and keep its edits, loot edit <change-id> reopens it as the working change, and loot new supersedes it. It takes the change id that loot log prints, not HEAD, and it reopens a tip only.

Read the log

$ loot op log
op 7    push        push → http://127.0.0.1:4000  heads {008f6887}  ⚠ barrier
op 6    restore     restored to op 4  heads {008f6887}
op 5    undo        undid op 4 (new)  heads {008f6887}
op 4    new         finalize 008f6887  heads {008f6887}
op 3    describe    named "move to 9090"  heads {008f6887}

Newest first. The log is local: it never travels in a push or a bundle, and each lane keeps its own.

What undo refuses

A step rewrites the working tree, so it refuses over edits no change records. Run loot describe first and they become an operation you can return to; --force discards them.

It also refuses to cross a barrier, an operation that disclosed something or changed keys, such as a push, a grant, a pull-grants, a maroon, a burn or a key rotation. loot op restore can’t jump back over one either.

loot: refusing to undo across a barrier (op 7, push → http://127.0.0.1:4000).
      a push discloses; it cannot be retracted by undo. to reverse a published change, record a new change or `loot maroon` the path.

Past a push, go forward. loot revert <selector> puts the inverse of a change in your working change; finalize it with loot new.

$ loot revert HEAD
revert 008f6887 as 57f08f54 "revert: move to 9090"
  app.conf                 merged

A revert undoes the content, not the disclosure: anyone who pulled still has the old version. Cutting off future access is loot maroon, and destroying the bytes is a burn, which no undo reverses. Known issues has more on what a push can’t take back.

What undo never touches

An undo moves pointers, never bytes. It doesn’t delete objects, drop or restore a key, withdraw a grant, or change your remotes and config.