Function: majutsu-workspace--prepare-trash-targets
majutsu-workspace--prepare-trash-targets is a natively compiled
function defined in majutsu-workspace.el.
Signature
(majutsu-workspace--prepare-trash-targets ROOT-ALIST)
Documentation
Validate ROOT-ALIST and record each existing root's file identifier.
ROOT-ALIST maps workspace names to directory paths. The returned target
plists contain :name, :root, :existed, and :identity. Nil roots and
already-missing paths are allowed because jj workspace forget is also useful
after a directory was removed manually.
Remote roots are rejected before any file operation. Existing targets must
be real directories, must not own the shared .jj/repo store, and must have
the same file identifier in the two validation checks.
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-workspace.el
(defun majutsu-workspace--prepare-trash-targets (root-alist)
"Validate ROOT-ALIST and record each existing root's file identifier.
ROOT-ALIST maps workspace names to directory paths. The returned target
plists contain `:name', `:root', `:existed', and `:identity'. Nil roots and
already-missing paths are allowed because `jj workspace forget' is also useful
after a directory was removed manually.
Remote roots are rejected before any file operation. Existing targets must
be real directories, must not own the shared `.jj/repo' store, and must have
the same file identifier in the two validation checks."
(mapcar
(lambda (entry)
(pcase-let ((`(,name . ,root) entry))
(cond
((or (null root) (string-empty-p root))
(list :name name :root root :existed nil :identity nil))
((file-remote-p root)
(user-error "Refusing to trash remote workspace %s at %s" name root))
(t
(let ((before (file-attributes root 'integer)))
(if (null before)
(list :name name :root root :existed nil :identity nil)
(unless (eq (file-attribute-type before) t)
(user-error "Refusing to trash workspace %s; %s is not a real directory"
name root))
(when (majutsu-workspace--repo-store-p root)
(user-error "Refusing to trash workspace %s; %s owns the shared .jj/repo store"
name root))
(let* ((after (file-attributes root 'integer))
(before-id (majutsu-workspace--directory-identity before))
(after-id (majutsu-workspace--directory-identity after)))
(unless (and before-id
(eq (file-attribute-type after) t)
(equal before-id after-id))
(user-error "Refusing to trash workspace %s; %s changed while it was validated"
name root))
(list :name name :root root :existed t :identity before-id))))))))
root-alist))