Fix ‘vc-p4-checkin’

- 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.
This commit is contained in:
Tom Willemse 2021-01-25 17:06:41 -08:00
parent 79262464fd
commit 39efc77e07

View file

@ -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)))))