Function: majutsu-workspace--trash-roots

majutsu-workspace--trash-roots is a natively compiled function defined in majutsu-workspace.el.

Signature

(majutsu-workspace--trash-roots TARGETS)

Documentation

Move eligible TARGETS to the system trash and return failure plists.

TARGETS must come from majutsu-workspace--prepare-trash-targets. Recheck each target after jj workspace forget. Ignore a target that was already absent and remains absent. Report a target that appears, disappears, is replaced, owns the shared repository store, or cannot be moved. Check all targets even after a failure.

Source Code

;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-workspace.el
(defun majutsu-workspace--trash-roots (targets)
  "Move eligible TARGETS to the system trash and return failure plists.

TARGETS must come from `majutsu-workspace--prepare-trash-targets'.  Recheck
each target after `jj workspace forget'.  Ignore a target that was already
absent and remains absent.  Report a target that appears, disappears, is
replaced, owns the shared repository store, or cannot be moved.  Check all
targets even after a failure."
  (let (failures)
    (dolist (target targets)
      (condition-case err
          (let* ((root (plist-get target :root))
                 (existed (plist-get target :existed))
                 (identity (plist-get target :identity))
                 (attributes (and root
                                  (not (string-empty-p root))
                                  (file-attributes root 'integer))))
            (cond
             ((and (not existed) (null attributes)))
             ((not existed)
              (push (majutsu-workspace--trash-target-failure
                     target "a filesystem object appeared there after confirmation")
                    failures))
             ((null attributes)
              (push (majutsu-workspace--trash-target-failure
                     target "the confirmed directory disappeared")
                    failures))
             ((or (not (eq (file-attribute-type attributes) t))
                  (not (equal identity
                              (majutsu-workspace--directory-identity attributes))))
              (push (majutsu-workspace--trash-target-failure
                     target "the directory identity changed after confirmation")
                    failures))
             ((majutsu-workspace--repo-store-p root)
              (push (majutsu-workspace--trash-target-failure
                     target "the directory now owns the shared .jj/repo store")
                    failures))
             (t
              (let ((delete-by-moving-to-trash t))
                (delete-directory root t t)))))
        (error
         (push (majutsu-workspace--trash-target-failure
                target (error-message-string err))
               failures))))
    (nreverse failures)))