Add client argument for checking in files

This commit is contained in:
Tom Willemse 2021-01-23 09:50:29 -08:00
parent 553914a5ac
commit 5c39509421
2 changed files with 18 additions and 9 deletions

View file

@ -398,7 +398,7 @@ Returns nil or raises an error on failure."
;; DO need to support "-i". ;; DO need to support "-i".
;; DO need to support specified changelist #'s. ;; DO need to support specified changelist #'s.
(defun p4-lowlevel-change (&optional buffer op) (cl-defun p4-lowlevel-change (&key buffer op client)
"Creates or edits a P4 changelist from/to BUFFER. "Creates or edits a P4 changelist from/to BUFFER.
If optional OP is a number, then the corresponding changelist is If optional OP is a number, then the corresponding changelist is
retrieved into BUFFER, or into a new buffer if BUFFER is nil. If OP retrieved into BUFFER, or into a new buffer if BUFFER is nil. If OP
@ -410,7 +410,8 @@ buffer is returned."
(let* ((input-buffer (if (and op (not (numberp op))) buffer nil)) (let* ((input-buffer (if (and op (not (numberp op))) buffer nil))
(flag-arg (if (or (not op) (numberp op)) "-o" "-i")) (flag-arg (if (or (not op) (numberp op)) "-o" "-i"))
(number-arg (if (numberp op) (list (number-to-string op)))) (number-arg (if (numberp op) (list (number-to-string op))))
(args (append (list "change" flag-arg) number-arg)) (client-args (if client (list "-c" client)))
(args (append client-args (list "change" flag-arg) number-arg))
alist info) alist info)
(setq alist (p4-lowlevel-command-or-error args input-buffer nil)) (setq alist (p4-lowlevel-command-or-error args input-buffer nil))
(setq info (p4-lowlevel-info-lines alist)) (setq info (p4-lowlevel-info-lines alist))
@ -684,9 +685,11 @@ resolve. Raises an error if the command fails."
;; Only need to support non-interactive use; therefore, only need to ;; Only need to support non-interactive use; therefore, only need to
;; support "p4 submit -i". ;; support "p4 submit -i".
(defun p4-lowlevel-submit (change-spec) (cl-defun p4-lowlevel-submit (change-spec &key client)
"Calls `p4 submit' on CHANGE-SPEC, which should be a string or buffer." "Calls `p4 submit' on CHANGE-SPEC, which should be a string or buffer."
(let (buffer) (let* ((client-args (if client (list "-c" client)))
(args (append client-args (list "submit" "-i")))
buffer)
(if (bufferp change-spec) (if (bufferp change-spec)
(setq buffer change-spec) (setq buffer change-spec)
(setq buffer (p4-lowlevel-get-buffer-create (setq buffer (p4-lowlevel-get-buffer-create
@ -695,7 +698,7 @@ resolve. Raises an error if the command fails."
(set-buffer buffer) (set-buffer buffer)
(erase-buffer) (erase-buffer)
(insert change-spec))) (insert change-spec)))
(p4-lowlevel-command-or-error (list "submit" "-i") buffer))) (p4-lowlevel-command-or-error args buffer)))
;; Here's what we need to support from the "p4 sync" command, at least for the ;; Here's what we need to support from the "p4 sync" command, at least for the
;; time being: ;; time being:

View file

@ -303,7 +303,7 @@ comment COMMENT."
(error "Can't specify revision for Perforce checkin.")) (error "Can't specify revision for Perforce checkin."))
(let* (;; XXX: default-directory? this should work for most (all?) cases (let* (;; XXX: default-directory? this should work for most (all?) cases
(default-directory (file-name-directory (car files))) (default-directory (file-name-directory (car files)))
(change-buffer (p4-lowlevel-change)) (change-buffer (p4-lowlevel-change :client vc-p4-client))
(indent-tabs-mode 1) (indent-tabs-mode 1)
insertion-start change-number) insertion-start change-number)
(dolist (file files) (dolist (file files)
@ -321,9 +321,15 @@ comment COMMENT."
(delete-region (point) (point-max)) (delete-region (point) (point-max))
(dolist (file files) (dolist (file files)
(insert "\t" (vc-file-getprop file 'vc-p4-depot-file) "\n")) (insert "\t" (vc-file-getprop file 'vc-p4-depot-file) "\n"))
(setq change-number (p4-lowlevel-change (current-buffer) t)) (setq change-number (p4-lowlevel-change
(p4-lowlevel-change (current-buffer) change-number) :buffer (current-buffer)
(p4-lowlevel-submit (current-buffer)) :op t
:client vc-p4-client))
(p4-lowlevel-change
:buffer (current-buffer)
:op change-number
:client vc-p4-client)
(p4-lowlevel-submit (current-buffer) :client vc-p4-client)
; Update its properties ; Update its properties
(dolist (file files) (dolist (file files)
(vc-p4-state file nil t))))) (vc-p4-state file nil t)))))