Function: vc-checkin
vc-checkin is a byte-compiled function defined in vc.el.gz.
Signature
(vc-checkin FILES BACKEND &optional COMMENT INITIAL-CONTENTS REV PATCH-STRING REGISTER)
Documentation
Check in FILES.
There are three calling conventions for the COMMENT and INITIAL-CONTENTS
optional arguments:
- COMMENT a string, INITIAL-CONTENTS nil means use that comment string
without prompting the user to edit it.
- COMMENT a string, INITIAL-CONTENTS non-nil means use that comment
string as the initial contents of the log entry buffer but stop for
editing.
- COMMENT t means check in immediately with an empty comment, and ignore
INITIAL-CONTENTS.
The optional argument REV may be a string specifying the new revision level (only supported for some older VCSes, like RCS and CVS). The optional argument PATCH-STRING is a string to check in as a patch. If the optional argument REGISTER is non-nil, it should be a list of files to register before checking in; if any of these are already registered the checkin will abort.
Runs the normal hooks vc-before-checkin-hook and vc-checkin-hook.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/vc.el.gz
(defun vc-checkin
(files backend &optional comment initial-contents rev patch-string register)
"Check in FILES.
There are three calling conventions for the COMMENT and INITIAL-CONTENTS
optional arguments:
- COMMENT a string, INITIAL-CONTENTS nil means use that comment string
without prompting the user to edit it.
- COMMENT a string, INITIAL-CONTENTS non-nil means use that comment
string as the initial contents of the log entry buffer but stop for
editing.
- COMMENT t means check in immediately with an empty comment, and ignore
INITIAL-CONTENTS.
The optional argument REV may be a string specifying the new revision
level (only supported for some older VCSes, like RCS and CVS).
The optional argument PATCH-STRING is a string to check in as a patch.
If the optional argument REGISTER is non-nil, it should be a list of
files to register before checking in; if any of these are already
registered the checkin will abort.
Runs the normal hooks `vc-before-checkin-hook' and `vc-checkin-hook'."
(run-hooks 'vc-before-checkin-hook)
(let ((do-async (and vc-async-checkin
(vc-call-backend backend 'async-checkins))))
(vc-start-logentry
files comment initial-contents
"Enter a change comment."
"*vc-log*"
(lambda ()
(vc-call-backend backend 'log-edit-mode))
(lambda (files comment)
;; Check the user isn't likely to be surprised by what is included
;; in the checkin. Once a log operation is started, the fileset
;; or patch string is locked in. In particular, it's probably too
;; late to offer to change it now -- checks in hooks and/or the
;; backend's Log Edit derived mode have all already okayed the
;; checkin. Restarting with the new fileset or patch is easy.
(let* ((start-again
(substitute-command-keys "\\[vc-next-action] to check in again"))
(instructions
(substitute-command-keys
(string-join
(list "type \\<log-edit-mode-map>\\[log-edit-kill-buffer] to cancel"
start-again
"\\[log-edit-previous-comment] to recall your message")
", "))))
(cond (patch-string
(unless (or (not (derived-mode-p 'diff-mode))
(equal patch-string (buffer-string))
(yes-or-no-p
(format-message "Patch in buffer \"%s\" \
has changed; continue with old patch?" (current-buffer))))
(user-error "%s %s"
"To check in the new patch" instructions)))
((vc-dispatcher-browsing)
(unless (or (and (length= files 1)
;; If no files in the dispatcher were
;; marked and it was just that point
;; moved to a different line, we don't
;; want to bother the user. This isn't
;; foolproof because we don't know
;; whether FILES was selected by means
;; of marking a single file or the
;; implicit selection of the file at
;; point in the absence of any marks.
(not (vc-dispatcher--explicit-marks-p)))
(equal files (cadr (vc-deduce-fileset)))
(yes-or-no-p
(format-message "Selected file(s) in buffer \"%s\" \
have changed; continue with old fileset?" (current-buffer))))
(user-error "%s %s"
"To use the new fileset" instructions)))))
;; "This log message intentionally left almost blank".
;; RCS 5.7 gripes about whitespace-only comments too.
(unless (and comment (string-match "[^\t\n ]" comment))
(setq comment "*** empty log message ***"))
(unless patch-string
;; Must not pass non-nil NOT-ESSENTIAL because we will shortly
;; call (in `vc-finish-logentry') `vc-resynch-buffer' with its
;; NOQUERY parameter non-nil.
(vc-buffer-sync-fileset (list backend files)))
(when register (vc-register (list backend register)))
(cl-flet ((do-it ()
;; We used to change buffers to get local value of
;; `vc-checkin-switches', but the (singular) local
;; buffer is not well defined for filesets.
(prog1 (if patch-string
(vc-call-backend backend 'checkin-patch
patch-string comment)
(vc-call-backend backend 'checkin
files comment rev))
(mapc #'vc-delete-automatic-version-backups files)))
(done-msg ()
(message "Checking in %s...done" (vc-delistify files))))
(if do-async
;; Rely on `vc-set-async-update' to update properties.
(let ((ret (do-it)))
(when (eq (car-safe ret) 'async)
(vc-exec-after #'done-msg nil (cadr ret)))
ret)
(prog2 (message "Checking in %s..." (vc-delistify files))
(with-vc-properties files (do-it)
`((vc-state . up-to-date)
(vc-checkout-time
. ,(file-attribute-modification-time
(file-attributes file)))
(vc-working-revision . nil)))
(done-msg)))))
'vc-checkin-hook
backend
patch-string)))