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"))))
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
return a list of the matching files."
(p4-lowlevel-items-matching-tag
"^info"
(p4-lowlevel-command-or-error
(list
"diff"
(format "-s%s" flag)
file))))
(let* ((client-args (if client (list "-c" client)))
(args (append client-args (list "diff" (format "-s%s" flag) file))))
(p4-lowlevel-command-or-error args))))
;; Here's what we need to support from the "p4 diff2" command, at least for the
;; time being:
@ -552,9 +550,11 @@ last LIMIT log entries."
(args (append (list "filelog") long-flag branch-flag limit-flag (list file))))
(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."
(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
;; time being:
@ -562,7 +562,7 @@ last LIMIT log entries."
;; Do NOT need to support any command-line switches.
;; 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).
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
@ -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."
(setq rev (p4-lowlevel-canonicalize-revision rev))
(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
"^info" (p4-lowlevel-command-or-error args nil nil noerror)))
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
: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 ()
"Return file.
Perforce has per-file revisions."
@ -114,7 +119,7 @@ Perforce has per-file revisions."
(getenv "P4CONFIG")
(not (vc-p4-find-p4config (file-name-directory file))))
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)
(assoc "headAction" 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."
(if (and (not force) (vc-file-getprop file 'vc-p4-did-fstat))
(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)
'unregistered
(let* (
@ -147,7 +152,7 @@ compare non-open files to the depot version."
((string= action "delete")
'removed)
(action
(let ((opened (p4-lowlevel-opened file)))
(let ((opened (p4-lowlevel-opened file :client vc-p4-client)))
(if (string-match " by \\([^@]+\\)@" opened)
(match-string 1 opened)
(if (equal headRev haveRev)
@ -155,7 +160,7 @@ compare non-open files to the depot version."
'needs-merge))))
((and (file-exists-p file)
(not dont-compare-nonopened)
(p4-lowlevel-diff-s file "e"))
(p4-lowlevel-diff-s file "e" :client vc-p4-client))
'unlocked-changes)
((or
(equal headRev haveRev)
@ -179,7 +184,8 @@ compare non-open files to the depot version."
;; XXX: this should be asynchronous.
(let ((lists (p4-lowlevel-fstat
(format "%s/..." (directory-file-name (expand-file-name dir)))
nil t)))
:noerror t
:client vc-p4-client)))
(when (stringp (caar lists))
(setq lists (list lists)))
(dolist (this-list lists)
@ -220,7 +226,7 @@ revision."
(not (equal (vc-file-getprop file 'vc-p4-action) "delete"))
(or (equal state 'up-to-date)
(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)
"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
;; interface yet, so just use the first file in the list.
(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))))
(if (string= action "delete")
(if (yes-or-no-p
@ -278,7 +284,7 @@ administered by Perforce."
(getenv "P4CONFIG")
(not (vc-p4-find-p4config file)))
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)
(file-name-as-directory file)
file)))))