;; Author: FSF (see vc.el for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org>
-;; $Id: vc-cvs.el,v 1.36 2002/03/18 17:19:45 spiegel Exp $
+;; $Id: vc-cvs.el,v 1.37 2002/03/22 23:10:01 monnier Exp $
;; This file is part of GNU Emacs.
;;; Customization options
;;;
+(defcustom vc-cvs-global-switches nil
+ "*Global switches to pass to any CVS command."
+ :type '(choice (const :tag "None" nil)
+ (string :tag "Argument String")
+ (repeat :tag "Argument List"
+ :value ("")
+ string))
+ :version "21.3"
+ :group 'vc)
+
(defcustom vc-cvs-register-switches nil
"*Extra switches for registering a file into CVS.
A string or list of strings passed to the checkin program by
state))
(with-temp-buffer
(cd (file-name-directory file))
- (vc-do-command t 0 "cvs" file "status")
+ (vc-cvs-command t 0 file "status")
(vc-cvs-parse-status t))))
(defun vc-cvs-state-heuristic (file)
;; Don't specify DIR in this command, the default-directory is
;; enough. Otherwise it might fail with remote repositories.
(with-temp-buffer
- (vc-do-command t 0 "cvs" nil "status" "-l")
+ (vc-cvs-command t 0 nil "status" "-l")
(goto-char (point-min))
(while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
(narrow-to-region (match-beginning 0) (match-end 0))
(list vc-cvs-register-switches)
vc-cvs-register-switches))))
- (apply 'vc-do-command nil 0 "cvs" file
+ (apply 'vc-cvs-command nil 0 file
"add"
(and comment (string-match "[^\t\n ]" comment)
(concat "-m" comment))
vc-checkin-switches))
status)
(if (not rev)
- (setq status (apply 'vc-do-command nil 1 "cvs" file
+ (setq status (apply 'vc-cvs-command nil 1 file
"ci" (if rev (concat "-r" rev))
(concat "-m" comment)
switches))
(error "%s is not a valid symbolic tag name")
;; If the input revison is a valid symbolic tag name, we create it
;; as a branch, commit and switch to it.
- (apply 'vc-do-command nil 0 "cvs" file "tag" "-b" (list rev))
- (apply 'vc-do-command nil 0 "cvs" file "update" "-r" (list rev))
- (setq status (apply 'vc-do-command nil 1 "cvs" file
+ (apply 'vc-cvs-command nil 0 file "tag" "-b" (list rev))
+ (apply 'vc-cvs-command nil 0 file "update" "-r" (list rev))
+ (setq status (apply 'vc-cvs-command nil 1 file
"ci"
(concat "-m" comment)
switches))
;; 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-do-command nil 0 "cvs" file "update" "-A"))))
+ (vc-cvs-command nil 0 file "update" "-A"))))
(defun vc-cvs-checkout (file &optional editable rev workfile)
"Retrieve a revision of FILE into a WORKFILE.
(let ((coding-system-for-read 'no-conversion)
(coding-system-for-write 'no-conversion))
(with-temp-file filename
- (apply 'vc-do-command
- (current-buffer) 0 "cvs" file
+ (apply 'vc-cvs-command
+ (current-buffer) 0 file
"-Q" ; suppress diagnostic output
"update"
(and rev (not (string= rev ""))
;; if necessary (using `cvs-edit' if requested).
(and editable (not (eq (vc-cvs-checkout-model file) 'implicit))
(if vc-cvs-use-edit
- (vc-do-command nil 0 "cvs" file "edit")
+ (vc-cvs-command nil 0 file "edit")
(set-file-modes file (logior (file-modes file) 128))
(if file-buffer (toggle-read-only -1))))
;; Check out a particular version (or recreate the file).
(vc-file-setprop file 'vc-workfile-version nil)
- (apply 'vc-do-command nil 0 "cvs" file
- (and editable
- (or (not (file-exists-p file))
- (not (eq (vc-cvs-checkout-model file)
- 'implicit)))
- "-w")
- "update"
- ;; default for verbose checkout: clear the sticky tag so
- ;; that the actual update will get the head of the trunk
+ (apply 'vc-cvs-command nil 0 file
+ (and editable
+ (or (not (file-exists-p file))
+ (not (eq (vc-cvs-checkout-model file)
+ 'implicit)))
+ "-w")
+ "update"
+ ;; default for verbose checkout: clear the sticky tag so
+ ;; that the actual update will get the head of the trunk
(if (or (not rev) (string= rev ""))
"-A"
(concat "-r" rev))
(vc-cvs-checkout file nil (vc-workfile-version file) file))
(unless (eq (vc-checkout-model file) 'implicit)
(if vc-cvs-use-edit
- (vc-do-command nil 0 "cvs" file "unedit")
+ (vc-cvs-command nil 0 file "unedit")
;; Make the file read-only by switching off all w-bits
(set-file-modes file (logand (file-modes file) 3950)))))
(defun vc-cvs-merge (file first-version &optional second-version)
"Merge changes into current working copy of FILE.
The changes are between FIRST-VERSION and SECOND-VERSION."
- (vc-do-command nil 0 "cvs" file
+ (vc-cvs-command nil 0 file
"update" "-kk"
(concat "-j" first-version)
(concat "-j" second-version))
(save-excursion
;; (vc-file-setprop file 'vc-workfile-version nil)
(vc-file-setprop file 'vc-checkout-time 0)
- (vc-do-command nil 0 "cvs" file "update")
+ (vc-cvs-command nil 0 file "update")
;; Analyze the merge result reported by CVS, and set
;; file properties accordingly.
(set-buffer (get-buffer "*vc*"))
(defun vc-cvs-print-log (file)
"Get change log associated with FILE."
- (vc-do-command
+ (vc-cvs-command
nil
(if (and (vc-cvs-stay-local-p file) (fboundp 'start-process)) 'async 0)
- "cvs" file "log"))
+ file "log"))
(defun vc-cvs-show-log-entry (version)
(when (re-search-forward
;; This file is added but not yet committed; there is no master file.
(if (or oldvers newvers)
(error "No revisions of %s exist" file)
- ;; we regard this as "changed".
- ;; diff it against /dev/null.
+ ;; We regard this as "changed".
+ ;; Diff it against /dev/null.
+ ;; Note: this is NOT a "cvs diff".
(apply 'vc-do-command "*vc-diff*"
1 "diff" file
(append diff-switches-list '("/dev/null"))))
(setq status
- (apply 'vc-do-command "*vc-diff*"
+ (apply 'vc-cvs-command "*vc-diff*"
(if (and (vc-cvs-stay-local-p file)
(fboundp 'start-process))
'async
1)
- "cvs" file "diff"
+ file "diff"
(and oldvers (concat "-r" oldvers))
(and newvers (concat "-r" newvers))
diff-switches-list))
;; cvs diff: use a single call for the entire tree
(let ((coding-system-for-read
(or coding-system-for-read 'undecided)))
- (apply 'vc-do-command "*vc-diff*" 1 "cvs" nil "diff"
+ (apply 'vc-cvs-command "*vc-diff*" 1 nil "diff"
(and rev1 (concat "-r" rev1))
(and rev2 (concat "-r" rev2))
(vc-diff-switches-list 'CVS))))))
(defun vc-cvs-annotate-command (file buffer &optional version)
"Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER.
Optional arg VERSION is a version to annotate from."
- (vc-do-command buffer 0 "cvs" file "annotate" (if version
+ (vc-cvs-command buffer 0 file "annotate" (if version
(concat "-r" version))))
(defun vc-cvs-annotate-current-time ()
"Assign to DIR's current version a given NAME.
If BRANCHP is non-nil, the name is created as a branch (and the current
workspace is immediately moved to that new branch)."
- (vc-do-command nil 0 "cvs" dir "tag" "-c" (if branchp "-b") name)
- (when branchp (vc-do-command nil 0 "cvs" dir "update" "-r" name)))
+ (vc-cvs-command nil 0 dir "tag" "-c" (if branchp "-b") name)
+ (when branchp (vc-cvs-command nil 0 dir "update" "-r" name)))
(defun vc-cvs-retrieve-snapshot (dir name update)
"Retrieve a snapshot at and below DIR.
(sticky-tag))
(erase-buffer)
(if (or (not name) (string= name ""))
- (vc-do-command t 0 "cvs" nil "update")
- (vc-do-command t 0 "cvs" nil "update" "-r" name)
+ (vc-cvs-command t 0 nil "update")
+ (vc-cvs-command t 0 nil "update" "-r" name)
(setq sticky-tag name))
(when update
(goto-char (point-min))
;;; Internal functions
;;;
+(defun vc-cvs-command (buffer okstatus file &rest flags)
+ "A wrapper around `vc-do-command' for use in vc-cvs.el.
+The difference to vc-do-command is that this function always invokes `cvs',
+and that it passes `vc-cvs-global-switches' to it before FLAGS."
+ (apply 'vc-do-command buffer okstatus "cvs" file
+ (if (stringp vc-cvs-global-switches)
+ (cons vc-cvs-global-switches flags)
+ (append vc-cvs-global-switches
+ flags))))
+
(defun vc-cvs-stay-local-p (file)
"Return non-nil if VC should stay local when handling FILE."
(if vc-cvs-stay-local