From 8c75982f016bfacdd5fbb55a1c03bd4c61e5a0c5 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sat, 23 Jan 2021 10:01:21 -0800 Subject: [PATCH] Add client argument for merging files --- p4-lowlevel.el | 22 ++++++++++++---------- vc-p4.el | 10 +++++++--- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/p4-lowlevel.el b/p4-lowlevel.el index 596539d..b17a2c2 100644 --- a/p4-lowlevel.el +++ b/p4-lowlevel.el @@ -660,11 +660,13 @@ Optional CHANGELIST specifies the changelist to which to move it." ;; Do NOT need to support "-v". ;; Do NOT need to support the specification of multiple files. -(defun p4-lowlevel-resolve (file) +(cl-defun p4-lowlevel-resolve (file &key client) "Call `p4 resolve' on FILE. Specifies the `-af' and `-t' options to ensure a non-interactive resolve. Raises an error if the command fails." - (p4-lowlevel-command-or-error (list "resolve" "-af" "-t" file))) + (let* ((client-args (if client (list "-c" client))) + (args (append client-args (list "resolve" "-af" "-t" file)))) + (p4-lowlevel-command-or-error args))) ;; Here's what we need to support from the "p4 revert" command, at least for the ;; time being: @@ -719,19 +721,19 @@ optional FORCE is non-nil, pass the `-f' flag." (args (append client-args (list "sync") force-args (list fullfile)))) (p4-lowlevel-command-or-error args))) -(defun p4-lowlevel-integrate (from-file to-file &optional rev1 rev2 force) +(cl-defun p4-lowlevel-integrate (from-file to-file &key rev1 rev2 force client) "Call `p4 integrate' from FROM-FILE to TO-FILE, with optional revision range specified by REV1 and REV2, forcing the integration (i.e., specifying `-f' to `p4 integrate' if FORCE is non-nil." (setq rev1 (p4-lowlevel-canonicalize-revision rev1) rev2 (p4-lowlevel-canonicalize-revision rev2)) - (let ((force-list (if force (list "-f"))) - (from-full (if (or rev1 rev2) - (format "%s%s,%s" from-file (or rev1 "") (or rev2 "")) - from-file))) - (p4-lowlevel-command-or-error (append (list "integrate") - (if force (list "-f")) - (list from-full to-file))))) + (let* ((force-arg (if force (list "-f"))) + (from-full (if (or rev1 rev2) + (format "%s%s,%s" from-file (or rev1 "") (or rev2 "")) + from-file)) + (client-args (if client (list "-c" client))) + (args (append client-args (list "integrate") force-arg (list from-full to-file)))) + (p4-lowlevel-command-or-error args))) (defun p4-lowlevel-client-version (&optional noerror) "Returns the Perforce client version string from `p4 -V'. diff --git a/vc-p4.el b/vc-p4.el index 803b85c..2f53a3f 100644 --- a/vc-p4.el +++ b/vc-p4.el @@ -370,8 +370,12 @@ comment COMMENT." (defun vc-p4-merge (file rev1 rev2) "Merge changes into Perforce FILE from REV1 to REV2." - (p4-lowlevel-integrate file file rev1 rev2 t) - (p4-lowlevel-resolve file) + (p4-lowlevel-integrate file file + :rev1 rev1 + :rev2 rev2 + :force t + :client vc-p4-client) + (p4-lowlevel-resolve file :client vc-p4-client) (vc-resynch-buffer file t t) (vc-p4-state file nil t) (if (vc-p4-has-unresolved-conflicts-p file) @@ -381,7 +385,7 @@ comment COMMENT." (defun vc-p4-merge-news (file) "Merge new changes from Perforce into FILE." (p4-lowlevel-sync file) - (p4-lowlevel-resolve file) + (p4-lowlevel-resolve file :client vc-p4-client) (vc-resynch-buffer file t t) (vc-p4-state file nil t) (if (vc-p4-has-unresolved-conflicts-p file)