From: Eli Zaretskii Date: Sat, 19 Sep 2015 10:31:38 +0000 (+0300) Subject: Resurrect the ability to specify a revision in vc-next-action X-Git-Tag: emacs-25.0.90~1224^2~81 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9ea6c4df441d85be44dadad4fbd57d2c0f3be4f1;p=emacs.git Resurrect the ability to specify a revision in vc-next-action * lisp/vc/vc-bzr.el (vc-bzr-checkin): * lisp/vc/vc-dav.el (vc-dav-checkin): * lisp/vc/vc-git.el (vc-git-checkin): * lisp/vc/vc-hg.el (vc-hg-checkin): * lisp/vc/vc-mtn.el (vc-mtn-checkin): Accept and silently ignore an additional optional argument, the revision to checkin. * lisp/vc/vc-sccs.el (vc-sccs-checkin): * lisp/vc/vc-cvs.el (vc-cvs-checkin): * lisp/vc/vc-rcs.el (vc-rcs-checkin): Allow to optionally specify a revision to checkin. * lisp/vc/vc.el (vc-next-action): Allow to optionally specify the revision when checking in files. See http://lists.gnu.org/archive/html/emacs-devel/2015-09/msg00688.html for the details. --- diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 5f8dd0bf0e8..9b2711d8146 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -649,7 +649,7 @@ or a superior directory.") "" (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 diff --git a/lisp/vc/vc-cvs.el b/lisp/vc/vc-cvs.el index 73ef42ac7d6..5f5807fb3c6 100644 --- a/lisp/vc/vc-cvs.el +++ b/lisp/vc/vc-cvs.el @@ -332,38 +332,20 @@ its parents." (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)) @@ -394,7 +376,11 @@ its parents." ;; 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 diff --git a/lisp/vc/vc-dav.el b/lisp/vc/vc-dav.el index 3326f2964c9..880e14be63e 100644 --- a/lisp/vc/vc-dav.el +++ b/lisp/vc/vc-dav.el @@ -82,7 +82,7 @@ See `vc-checkout-model' for a list of possible values." ;; 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. ) diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 8a0f5547c4d..2f0439365e8 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -674,7 +674,7 @@ If toggling on, also insert its message into the buffer." "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)) diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index f634e2eac53..49573986125 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -465,7 +465,7 @@ Optional arg REVISION is a revision to annotate from." (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 diff --git a/lisp/vc/vc-mtn.el b/lisp/vc/vc-mtn.el index 685ef3b6742..b56a08f2a9e 100644 --- a/lisp/vc/vc-mtn.el +++ b/lisp/vc/vc-mtn.el @@ -199,7 +199,7 @@ switches." (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") diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el index 995bd059f2d..ba1336424ea 100644 --- a/lisp/vc/vc-rcs.el +++ b/lisp/vc/vc-rcs.el @@ -306,27 +306,23 @@ whether to remove it." (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") diff --git a/lisp/vc/vc-sccs.el b/lisp/vc/vc-sccs.el index 8d8d9e844ed..a3facc56d5d 100644 --- a/lisp/vc/vc-sccs.el +++ b/lisp/vc/vc-sccs.el @@ -222,10 +222,11 @@ to the SCCS command." (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)))) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 90d450a5ab9..f08e562efe5 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -233,12 +233,13 @@ ;; 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) ;; @@ -1221,10 +1222,15 @@ For old-style locking-based version control systems, like RCS: (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 @@ -1522,11 +1528,13 @@ Type \\[vc-next-action] to check in changes.") ".\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 @@ -1549,7 +1557,7 @@ Runs the normal hooks `vc-before-checkin-hook' and `vc-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)))