Specify client for initial responsibility check

This commit is contained in:
Tom Willemse 2021-01-21 19:12:15 -08:00
parent 4c5fc58d6d
commit 6724d2b827
2 changed files with 25 additions and 18 deletions

View file

@ -484,16 +484,14 @@ that buffer."
(or buffer "diff")))) (or buffer "diff"))))
buffer)) buffer))
(defun p4-lowlevel-diff-s (file flag) (defun p4-lowlevel-diff-s (file flag &key client)
"Run `p4 diff -s' on FILE, using FLAG as the argument to `-s', and "Run `p4 diff -s' on FILE, using FLAG as the argument to `-s', and
return a list of the matching files." return a list of the matching files."
(p4-lowlevel-items-matching-tag (p4-lowlevel-items-matching-tag
"^info" "^info"
(p4-lowlevel-command-or-error (let* ((client-args (if client (list "-c" client)))
(list (args (append client-args (list "diff" (format "-s%s" flag) file))))
"diff" (p4-lowlevel-command-or-error args))))
(format "-s%s" flag)
file))))
;; Here's what we need to support from the "p4 diff2" command, at least for the ;; Here's what we need to support from the "p4 diff2" command, at least for the
;; time being: ;; time being:
@ -552,9 +550,11 @@ last LIMIT log entries."
(args (append (list "filelog") long-flag branch-flag limit-flag (list file)))) (args (append (list "filelog") long-flag branch-flag limit-flag (list file))))
(p4-lowlevel-command-into-buffer args (or buffer "log")))) (p4-lowlevel-command-into-buffer args (or buffer "log"))))
(defun p4-lowlevel-opened (file) (cl-defun p4-lowlevel-opened (file &key client)
"Fetch the string returned by running `p4 opened' on FILE." "Fetch the string returned by running `p4 opened' on FILE."
(p4-lowlevel-command-or-error (list "opened" file) nil 'string)) (let* ((client-args (if client (list "-c" client)))
(args (append client-args (list "opened" file))))
(p4-lowlevel-command-or-error args nil 'string)))
;; Here's what we need to support from the "p4 fstat" command, at least for the ;; Here's what we need to support from the "p4 fstat" command, at least for the
;; time being: ;; time being:
@ -562,7 +562,7 @@ last LIMIT log entries."
;; Do NOT need to support any command-line switches. ;; Do NOT need to support any command-line switches.
;; Do NOT need to support the specification of multiple files. ;; Do NOT need to support the specification of multiple files.
(defun p4-lowlevel-fstat (file &optional rev noerror) (cl-defun p4-lowlevel-fstat (file &key rev noerror client)
"Fetch p4 information about FILE (optionally, at REV). "Fetch p4 information about FILE (optionally, at REV).
REV should be in the syntax described by `p4 help revisions'. Returns REV should be in the syntax described by `p4 help revisions'. Returns
a list of field-name/value elements on success, or raises an error on a list of field-name/value elements on success, or raises an error on
@ -571,7 +571,8 @@ rather than raising an error on failure. If FILE matches multiple
files, then returns a list of lists of field-name/value elements." files, then returns a list of lists of field-name/value elements."
(setq rev (p4-lowlevel-canonicalize-revision rev)) (setq rev (p4-lowlevel-canonicalize-revision rev))
(let* ((file-spec (if rev (concat file rev) file)) (let* ((file-spec (if rev (concat file rev) file))
(args (list "fstat" file-spec)) (client-args (when client (list "-c" client)))
(args (append client-args (list "fstat" file-spec)))
(alist (p4-lowlevel-re-assoc (alist (p4-lowlevel-re-assoc
"^info" (p4-lowlevel-command-or-error args nil nil noerror))) "^info" (p4-lowlevel-command-or-error args nil nil noerror)))
element line field value values lists) element line field value values lists)

View file

@ -99,6 +99,11 @@ specify a starting date when you run C-u C-x v g."
:type 'string :type 'string
:group 'vc) :group 'vc)
(defcustom vc-p4-client nil
"Specifies the client to use when connecting to Perforce."
:type 'string
:group 'vc)
(defun vc-p4-revision-granularity () (defun vc-p4-revision-granularity ()
"Return file. "Return file.
Perforce has per-file revisions." Perforce has per-file revisions."
@ -114,7 +119,7 @@ Perforce has per-file revisions."
(getenv "P4CONFIG") (getenv "P4CONFIG")
(not (vc-p4-find-p4config (file-name-directory file)))) (not (vc-p4-find-p4config (file-name-directory file))))
nil nil
(let* ((fstat (p4-lowlevel-fstat file nil t)) (let* ((fstat (p4-lowlevel-fstat file :noerror t :client vc-p4-client))
(action (cdr (or (assoc "action" fstat) (action (cdr (or (assoc "action" fstat)
(assoc "headAction" fstat))))) (assoc "headAction" fstat)))))
(if (or (not fstat) (if (or (not fstat)
@ -133,7 +138,7 @@ previously fetched. If DONT-COMPARE-NONOPENED is non-nil, don't
compare non-open files to the depot version." compare non-open files to the depot version."
(if (and (not force) (vc-file-getprop file 'vc-p4-did-fstat)) (if (and (not force) (vc-file-getprop file 'vc-p4-did-fstat))
(vc-file-getprop file 'vc-state) (vc-file-getprop file 'vc-state)
(let ((alist (or fstat-list (p4-lowlevel-fstat file nil t)))) (let ((alist (or fstat-list (p4-lowlevel-fstat file :noerror t :client vc-p4-client))))
(if (null alist) (if (null alist)
'unregistered 'unregistered
(let* ( (let* (
@ -147,7 +152,7 @@ compare non-open files to the depot version."
((string= action "delete") ((string= action "delete")
'removed) 'removed)
(action (action
(let ((opened (p4-lowlevel-opened file))) (let ((opened (p4-lowlevel-opened file :client vc-p4-client)))
(if (string-match " by \\([^@]+\\)@" opened) (if (string-match " by \\([^@]+\\)@" opened)
(match-string 1 opened) (match-string 1 opened)
(if (equal headRev haveRev) (if (equal headRev haveRev)
@ -155,7 +160,7 @@ compare non-open files to the depot version."
'needs-merge)))) 'needs-merge))))
((and (file-exists-p file) ((and (file-exists-p file)
(not dont-compare-nonopened) (not dont-compare-nonopened)
(p4-lowlevel-diff-s file "e")) (p4-lowlevel-diff-s file "e" :client vc-p4-client))
'unlocked-changes) 'unlocked-changes)
((or ((or
(equal headRev haveRev) (equal headRev haveRev)
@ -179,7 +184,8 @@ compare non-open files to the depot version."
;; XXX: this should be asynchronous. ;; XXX: this should be asynchronous.
(let ((lists (p4-lowlevel-fstat (let ((lists (p4-lowlevel-fstat
(format "%s/..." (directory-file-name (expand-file-name dir))) (format "%s/..." (directory-file-name (expand-file-name dir)))
nil t))) :noerror t
:client vc-p4-client)))
(when (stringp (caar lists)) (when (stringp (caar lists))
(setq lists (list lists))) (setq lists (list lists)))
(dolist (this-list lists) (dolist (this-list lists)
@ -220,7 +226,7 @@ revision."
(not (equal (vc-file-getprop file 'vc-p4-action) "delete")) (not (equal (vc-file-getprop file 'vc-p4-action) "delete"))
(or (equal state 'up-to-date) (or (equal state 'up-to-date)
(equal state 'needs-patch) (equal state 'needs-patch)
(p4-lowlevel-diff-s file "r"))))) (p4-lowlevel-diff-s file "r" :client vc-p4-client)))))
(defun vc-p4-mode-line-string (file) (defun vc-p4-mode-line-string (file)
"Return string for placement into the modeline for FILE. "Return string for placement into the modeline for FILE.
@ -250,7 +256,7 @@ special case of a Perforce file that is added but not yet committed."
;; before it used to be just a single file. We don't support that ;; before it used to be just a single file. We don't support that
;; interface yet, so just use the first file in the list. ;; interface yet, so just use the first file in the list.
(let* ((file (if (listp files) (car files) files)) (let* ((file (if (listp files) (car files) files))
(fstat (p4-lowlevel-fstat file nil t)) (fstat (p4-lowlevel-fstat file :noerror t :client vc-p4-client))
(action (cdr (assoc "action" fstat)))) (action (cdr (assoc "action" fstat))))
(if (string= action "delete") (if (string= action "delete")
(if (yes-or-no-p (if (yes-or-no-p
@ -278,7 +284,7 @@ administered by Perforce."
(getenv "P4CONFIG") (getenv "P4CONFIG")
(not (vc-p4-find-p4config file))) (not (vc-p4-find-p4config file)))
nil nil
(or (p4-lowlevel-fstat file nil t) (or (p4-lowlevel-fstat file :noerror t :client vc-p4-client)
(vc-p4-is-in-client (if (file-directory-p file) (vc-p4-is-in-client (if (file-directory-p file)
(file-name-as-directory file) (file-name-as-directory file)
file))))) file)))))