Function: majutsu-workspace-add
majutsu-workspace-add is an interactive and natively compiled function
defined in majutsu-workspace.el.
Signature
(majutsu-workspace-add DESTINATION &optional NAME REVISION SPARSE-PATTERNS)
Documentation
Add a workspace.
DESTINATION is where to create the new workspace.
Optional NAME, REVISION (revset), and SPARSE-PATTERNS correspond to
`jj workspace add` options.
Key Bindings
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/jagqw3nms546pad0gxi5f3wsckk6pji7-emacs-packages-deps/share/emacs/site-lisp/majutsu-workspace.el
;;;###autoload
(defun majutsu-workspace-add (destination &optional name revision sparse-patterns)
"Add a workspace.
DESTINATION is where to create the new workspace.
Optional NAME, REVISION (revset), and SPARSE-PATTERNS correspond to
`jj workspace add` options."
(interactive
(let* ((root (majutsu--toplevel-safe))
(name (string-trim
(or (majutsu-completing-read
"Workspace name (empty = default)"
(majutsu-workspace--names root)
nil nil nil 'majutsu-workspace-name-history
nil 'majutsu-workspace)
"")))
(destination (majutsu-workspace--read-add-destination root name))
(revision (or (majutsu-read-revset
"Parent revset (-r, empty = default)"
:allow-empty t
:history 'majutsu-read-revset-history)
""))
(sparse (majutsu-completing-read "Sparse patterns"
'("copy" "full" "empty") nil t nil nil "copy")))
(list destination
(unless (string-empty-p name) name)
(unless (string-empty-p revision) revision)
(unless (equal sparse "copy") sparse))))
(let* ((dest (expand-file-name destination))
(args (append (list "workspace" "add" (majutsu-convert-filename-for-jj dest))
(and name (list "--name" name))
(and revision (list "--revision" revision))
(and sparse-patterns (list "--sparse-patterns" sparse-patterns))))
(exit (apply #'majutsu-run-jj args)))
(if (zerop exit)
(progn
(message "Workspace created in %s" dest)
;; Like Magit, visit the new workspace.
(majutsu-workspace-visit dest))
(message "Workspace creation failed"))))