"" (replace-regexp-in-string
"\n[ \t]?" " " str)))))
-(defun vc-bzr-checkin (files comment)
+(defun vc-bzr-checkin (files comment &optional _rev)
"Check FILES in to bzr with log message COMMENT."
(apply 'vc-bzr-command "commit" nil 0 files
(cons "-m" (log-edit-extract-headers
(directory-file-name dir))))
(eq dir t)))
-;; vc-cvs-checkin used to take a 'rev' second argument that allowed
-;; checking in onto a specified branch tip rather than the current
-;; default branch, but nothing in the entire rest of VC exercised
-;; this code. Removing it simplifies the backend interface for all
-;; modes.
-;;
-;; Here's the setup code preserved in amber, in case the logic needs
-;; to be broken out into a method someday; (if rev (concat "-r" rev))
-;; used to be part of the switches passed to vc-cvs-command.
-;;
-;; (unless (or (not rev) (vc-cvs-valid-revision-number-p rev))
-;; (if (not (vc-cvs-valid-symbolic-tag-name-p rev))
-;; (error "%s is not a valid symbolic tag name" rev)
-;; ;; If the input revision is a valid symbolic tag name, we create it
-;; ;; as a branch, commit and switch to it.
-;; (apply 'vc-cvs-command nil 0 files "tag" "-b" (list rev))
-;; (apply 'vc-cvs-command nil 0 files "update" "-r" (list rev))
-;; (mapc (lambda (file) (vc-file-setprop file 'vc-cvs-sticky-tag rev))
-;; files)))
-;;
-;; The following postamble cleaned up after the branch change:
-;;
-;; ;; if this was an explicit check-in (does not include creation of
-;; ;; a branch), remove the sticky tag.
-;; (if (and rev (not (vc-cvs-valid-symbolic-tag-name-p rev)))
-;; (vc-cvs-command nil 0 files "update" "-A"))))
-;; files)))
-;;
-(defun vc-cvs-checkin (files comment)
+(defun vc-cvs-checkin (files comment &optional rev)
"CVS-specific version of `vc-backend-checkin'."
+ (unless (or (not rev) (vc-cvs-valid-revision-number-p rev))
+ (if (not (vc-cvs-valid-symbolic-tag-name-p rev))
+ (error "%s is not a valid symbolic tag name" rev)
+ ;; If the input revision is a valid symbolic tag name, we create it
+ ;; as a branch, commit and switch to it.
+ (apply 'vc-cvs-command nil 0 files "tag" "-b" (list rev))
+ (apply 'vc-cvs-command nil 0 files "update" "-r" (list rev))
+ (mapc (lambda (file) (vc-file-setprop file 'vc-cvs-sticky-tag rev))
+ files)))
(let ((status (apply 'vc-cvs-command nil 1 files
- "ci" (concat "-m" comment)
+ "ci" (if rev (concat "-r" rev))
+ (concat "-m" comment)
(vc-switches 'CVS 'checkin))))
(set-buffer "*vc*")
(goto-char (point-min))
;; tell it from the permissions of the file (see
;; vc-cvs-checkout-model).
(mapc (lambda (file) (vc-file-setprop file 'vc-checkout-model nil))
- files)))
+ files)
+ ;; if this was an explicit check-in (does not include creation of
+ ;; a branch), remove the sticky tag.
+ (if (and rev (not (vc-cvs-valid-symbolic-tag-name-p rev)))
+ (vc-cvs-command nil 0 files "update" "-A"))))
(defun vc-cvs-find-revision (file rev buffer)
(apply 'vc-cvs-command
;; Do we need to do anything here? FIXME?
)
-(defun vc-dav-checkin (url comment)
+(defun vc-dav-checkin (url comment &optional _rev)
"Commit changes in URL to WebDAV. COMMENT is used as a check-in comment."
;; This should PUT the resource and release any locks that we hold.
)
"Major mode for editing Git log messages.
It is based on `log-edit-mode', and has Git-specific extensions.")
-(defun vc-git-checkin (files comment)
+(defun vc-git-checkin (files comment &optional _rev)
(let* ((file1 (or (car files) default-directory))
(root (vc-git-root file1))
(default-directory (expand-file-name root))
(declare-function log-edit-extract-headers "log-edit" (headers string))
-(defun vc-hg-checkin (files comment)
+(defun vc-hg-checkin (files comment &optional _rev)
"Hg-specific version of `vc-backend-checkin'.
REV is ignored."
(apply 'vc-hg-command nil 0 files
(declare-function log-edit-extract-headers "log-edit" (headers string))
-(defun vc-mtn-checkin (files comment)
+(defun vc-mtn-checkin (files comment &optional _rev)
(apply 'vc-mtn-command nil 0 files
(nconc (list "commit" "-m")
(log-edit-extract-headers '(("Author" . "--author")
(yes-or-no-p (format "Directory %s is empty; remove it? " dir))
(delete-directory dir)))))
-;; It used to be possible to pass in a value for the variable rev, but
-;; nothing in the rest of VC used this capability. Removing it makes the
-;; backend interface simpler for all modes.
-;;
-(defun vc-rcs-checkin (files comment)
+(defun vc-rcs-checkin (files comment &optional rev)
"RCS-specific version of `vc-backend-checkin'."
- (let (rev (switches (vc-switches 'RCS 'checkin)))
+ (let ((switches (vc-switches 'RCS 'checkin)))
;; Now operate on the files
(dolist (file (vc-expand-dirs files 'RCS))
(let ((old-version (vc-working-revision file)) new-version
(default-branch (vc-file-getprop file 'vc-rcs-default-branch)))
;; Force branch creation if an appropriate
;; default branch has been set.
- (and default-branch
+ (and (not rev)
+ default-branch
(string-match (concat "^" (regexp-quote old-version) "\\.")
default-branch)
(setq rev default-branch)
(setq switches (cons "-f" switches)))
- (if old-version
- (setq rev (vc-branch-part old-version))
- (error "can't find current branch"))
+ (if (and (not rev) old-version)
+ (setq rev (vc-branch-part old-version)))
(apply #'vc-do-command "*vc*" 0 "ci" (vc-master-name file)
;; if available, use the secure check-in option
(and (vc-rcs-release-p "5.6.4") "-j")
(stringp (vc-sccs-search-project-dir (or (file-name-directory file) "")
(file-name-nondirectory file)))))
-(defun vc-sccs-checkin (files comment)
+(defun vc-sccs-checkin (files comment &optional rev)
"SCCS-specific version of `vc-backend-checkin'."
(dolist (file (vc-expand-dirs files 'SCCS))
(apply 'vc-sccs-do-command nil 0 "delta" (vc-master-name file)
+ (if rev (concat "-r" rev))
(concat "-y" comment)
(vc-switches 'SCCS 'checkin))
(vc-sccs-do-command nil 0 "get" (vc-master-name file))))
;; Unregister FILE from this backend. This is only needed if this
;; backend may be used as a "more local" backend for temporary editing.
;;
-;; * checkin (files comment)
+;; * checkin (files comment &optional rev)
;;
;; Commit changes in FILES to this backend. COMMENT is used as a
;; check-in comment. The implementation should pass the value of
-;; vc-checkin-switches to the backend command. The revision argument
-;; of some older VC versions is no longer supported.
+;; vc-checkin-switches to the backend command. The optional REV
+;; revision argument is only supported with some older VCSes, like
+;; RCS and CVS, and is otherwise silently ignored.
;;
;; * find-revision (file rev buffer)
;;
(message "No files remain to be committed")
(if (not verbose)
(vc-checkin ready-for-commit backend)
- (let ((new-backend (vc-read-backend "New backend: ")))
- (if new-backend
- (dolist (file files)
- (vc-transfer-file file new-backend))))))))
+ (let* ((revision (read-string "New revision or backend: "))
+ (revision-downcase (downcase revision)))
+ (if (member
+ revision-downcase
+ (mapcar (lambda (arg) (downcase (symbol-name arg)))
+ vc-handled-backends))
+ (let ((vsym (intern revision-downcase)))
+ (dolist (file files) (vc-transfer-file file vsym)))
+ (vc-checkin ready-for-commit backend nil nil revision)))))))
;; locked by somebody else (locking VCSes only)
((stringp state)
;; In the old days, we computed the revision once and used it on
".\n")
(message "Please explain why you stole the lock. Type C-c C-c when done.")))
-(defun vc-checkin (files backend &optional comment initial-contents)
+(defun vc-checkin (files backend &optional comment initial-contents rev)
"Check in FILES. COMMENT is a comment string; if omitted, a
buffer is popped up to accept a comment. If INITIAL-CONTENTS is
non-nil, then COMMENT is used as the initial contents of the log
entry buffer.
+The optional argument REV may be a string specifying the new revision
+level (only supported for some older VCSes, like RCS and CVS).
Runs the normal hooks `vc-before-checkin-hook' and `vc-checkin-hook'."
(when vc-before-checkin-hook
;; vc-checkin-switches, but 'the' local buffer is
;; not a well-defined concept for filesets.
(progn
- (vc-call-backend backend 'checkin files comment)
+ (vc-call-backend backend 'checkin files comment rev)
(mapc 'vc-delete-automatic-version-backups files))
`((vc-state . up-to-date)
(vc-checkout-time . ,(nth 5 (file-attributes file)))