Add simplistic vc-p4-switch-client command
This commit is contained in:
parent
58a8b9efc6
commit
774ab55e9e
2 changed files with 46 additions and 0 deletions
|
@ -726,4 +726,45 @@ already exists."
|
|||
(setq default-directory caller-default-directory))
|
||||
buf))
|
||||
|
||||
(defun p4-lowlevel-local-clients ()
|
||||
(mapcar (lambda (client) (alist-get "client" client nil nil #'string=))
|
||||
(seq-filter (lambda (client) (string= (alist-get "Host" client nil nil #'string=)
|
||||
(system-name)))
|
||||
(p4-lowlevel-clients))))
|
||||
|
||||
(defun p4-lowlevel-clients ()
|
||||
"Get the clients available."
|
||||
(let ((lines (p4-lowlevel-command-to-alist `("-z" "tag" "clients" "-u" ,(user-login-name)))))
|
||||
(seq-reduce (lambda (acc itm)
|
||||
(p4-lowlevel-clients-parse-line acc itm))
|
||||
lines nil)))
|
||||
|
||||
(defun p4-lowlevel-clients-parse-line (acc line)
|
||||
(pcase (car line)
|
||||
((pred (string= "info1"))
|
||||
(let ((values (split-string (cdr line) " ")))
|
||||
(pcase (car values)
|
||||
((pred (string= "client"))
|
||||
(cons (list (cons (car values) (cadr values))) acc))
|
||||
((or (pred (string= "Update"))
|
||||
(pred (string= "Access"))
|
||||
(pred (string= "Owner"))
|
||||
(pred (string= "Options"))
|
||||
(pred (string= "SubmitOptions"))
|
||||
(pred (string= "LineEnd"))
|
||||
(pred (string= "Root"))
|
||||
(pred (string= "Host"))
|
||||
(pred (string= "Stream"))
|
||||
(pred (string= "Type"))
|
||||
(pred (string= "Description")))
|
||||
(cons (cons (cons (car values)
|
||||
(cadr values))
|
||||
(car acc))
|
||||
(cdr acc)))
|
||||
(_ acc))))
|
||||
(`("exit" . ,result)
|
||||
(if (not (= result 0))
|
||||
(error "Clients returned non-zero exit code.")))
|
||||
(_ acc)))
|
||||
|
||||
(provide 'p4-lowlevel)
|
||||
|
|
5
vc-p4.el
5
vc-p4.el
|
@ -980,4 +980,9 @@ third subblock in each conflict block."
|
|||
The difference to vc-do-command is that this function always invokes `p4'."
|
||||
(apply 'vc-do-command buffer okstatus "p4" file flags))
|
||||
|
||||
(defun vc-p4-switch-client (client)
|
||||
(interactive
|
||||
(list (completing-read "Client: " (p4-lowlevel-local-clients))))
|
||||
(p4-lowlevel-command-or-error `("set" ,(format "P4CLIENT=%s" client))))
|
||||
|
||||
(provide 'vc-p4)
|
||||
|
|
Loading…
Reference in a new issue