From 39efc77e07611e24bc4d3fe789eec6a0f8906de0 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 25 Jan 2021 17:06:41 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20=E2=80=98vc-p4-checkin=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The arguments ‘comment’ and ‘rev’ have been switched. I don’t know if this used to be different from how it is now, but ‘rev’ comes last now and is optional. - The ‘vc-p4-client’ needs to be collected from the first file in the list of files to check in because ‘vc-p4-checkin’ is called from a different buffer that isn’t in the same directory. - ‘vc-p4-client’ also needs to be stored under a different name so that when it changes to the ‘*p4-lowlevel-changes*’ buffer it doesn’t clear the value. - Instead of inserting the specified comment directly, send it through ‘log-edit-extract-headers’ which removes the "Summary: " header that ‘vc-log-edit’ adds. - Indent rigidly to ‘tab-width’ instead of 8. Indenting to 8 added too many tabs to the description and caused all lines to be prefixed by a tab. --- vc-p4.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/vc-p4.el b/vc-p4.el index 4ea6d09..021a7ca 100644 --- a/vc-p4.el +++ b/vc-p4.el @@ -296,14 +296,17 @@ administered by Perforce." :quiet t :client vc-p4-client)) -(defun vc-p4-checkin (files rev comment) +(defun vc-p4-checkin (files comment &optional rev) "Check FILES into Perforce. Error if REV is non-nil. Check in with comment COMMENT." (if rev (error "Can't specify revision for Perforce checkin.")) (let* (;; XXX: default-directory? this should work for most (all?) cases (default-directory (file-name-directory (car files))) - (change-buffer (p4-lowlevel-change :client vc-p4-client)) + (current-client + (with-current-buffer (find-file-noselect (car files)) + vc-p4-client)) + (change-buffer (p4-lowlevel-change :client current-client)) (indent-tabs-mode 1) insertion-start change-number) (dolist (file files) @@ -315,8 +318,8 @@ comment COMMENT." (re-search-forward "^Description:\\s-*\n") (kill-line 1) (setq insertion-start (point)) - (insert comment "\n") - (indent-rigidly insertion-start (point) 8) + (insert (car (log-edit-extract-headers nil comment)) "\n") + (indent-rigidly insertion-start (point) tab-width) (re-search-forward "^Files:\\s-*\n") (delete-region (point) (point-max)) (dolist (file files) @@ -324,12 +327,12 @@ comment COMMENT." (setq change-number (p4-lowlevel-change :buffer (current-buffer) :op t - :client vc-p4-client)) + :client current-client)) (p4-lowlevel-change :buffer (current-buffer) :op change-number - :client vc-p4-client) - (p4-lowlevel-submit (current-buffer) :client vc-p4-client) + :client current-client) + (p4-lowlevel-submit (current-buffer) :client current-client) ; Update its properties (dolist (file files) (vc-p4-state file nil t)))))