Expand description
Backup session management for undo safety net.
size-waiver: accepted single-domain bulk (policy #1408). Session create, path sanitization, list/restore/prune, and host restore helper are one unit; tests co-located. Do not split for LOC alone (#1494 restore API).
Before any --apply write, commands save the original content of each
affected file to .patchloom/backups/<timestamp>/. The patchloom undo
command restores the most recent (or a chosen) backup.
Structs§
- Backup
Session - An active backup session that collects originals before writes.
- List
Sessions Options - Options for
list_sessions_under(#1688). - Manifest
- The manifest for a backup session.
- Manifest
Entry - A single file entry in the backup manifest.
- Session
Listing - One backup root plus its sessions (newest first), for nested monorepo layouts (#1688).
Enums§
- File
Action - What the apply operation did to a file.
Constants§
- BACKUP_
DIR - Directory name under the project root.
Functions§
- backup_
write_ files - Back up files, write new content atomically, and finalize the backup session. All originals are saved before any writes begin, ensuring consistency.
- find_
backup_ roots - Walk
pathand its parent directories for roots that contain.patchloom/backups. - is_
under_ backup_ dir - True when
pathis inside a.patchloom/backupstree (any ancestor). - list_
sessions - List available backup sessions, most recent first.
- list_
sessions_ under - List backup sessions under
project_root, optionally walking nested crates. - prune_
old_ backups - Prune backup sessions older than 7 days.
- refuse_
user_ write_ under_ backup_ dir - Refuse a user write whose destination is under
BACKUP_DIR. - remove_
session - Remove a consumed backup session directory so subsequent
undocalls reach older sessions instead of replaying the same one. - restore_
path_ from_ latest_ backup - Restore a single path from the most recent backup session that contains it.
- restore_
path_ from_ session - Restore one path from a specific backup session (exact path match only).
- restore_
path_ from_ session_ with_ guard - Like
restore_path_from_session, with optionalPathGuard. - restore_
session - Restore a specific backup session, returning the number of files restored.
- restore_
session_ with_ guard - Restore a backup session, refusing targets outside
guardwhen set.