;;; vc-rcs.el --- support for RCS version-control
-;; Copyright (C) 1992,93,94,95,96,97,98,99,2000 Free Software Foundation, Inc.
+;; Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Andre Spiegel <spiegel@gnu.org>
-;; $Id: vc-rcs.el,v 1.11 2000/10/03 12:08:40 spiegel Exp $
+;; $Id: vc-rcs.el,v 1.23 2002/02/25 22:04:29 spiegel Exp $
;; This file is part of GNU Emacs.
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
-;;; Commentary: see vc.el
+;;; Commentary:
+
+;; See vc.el
;;; Code:
;;;
(eval-when-compile
- (require 'cl))
+ (require 'cl)
+ (require 'vc))
(defcustom vc-rcs-release nil
"*The release number of your RCS installation, as a string.
:version "21.1"
:group 'vc)
-(defcustom vc-rcs-checkin-switches nil
- "*A string or list of strings specifying extra switches for RCS checkin.
-These are passed to the checkin program by \\[vc-rcs-checkin]."
- :type '(choice (const :tag "None" nil)
- (string :tag "Argument String")
- (repeat :tag "Argument List"
- :value ("")
- string))
- :version "21.1"
- :group 'vc)
-
-(defcustom vc-rcs-checkout-switches nil
- "*A string or list of strings specifying extra switches for RCS checkout.
-These are passed to the checkout program by \\[vc-rcs-checkout]."
+(defcustom vc-rcs-diff-switches nil
+ "*A string or list of strings specifying extra switches for rcsdiff under VC."
:type '(choice (const :tag "None" nil)
(string :tag "Argument String")
(repeat :tag "Argument List"
(defcustom vc-rcs-header (or (cdr (assoc 'RCS vc-header-alist)) '("\$Id\$"))
"*Header keywords to be inserted by `vc-insert-headers'."
- :type 'string
+ :type '(repeat string)
:version "21.1"
:group 'vc)
(vc-rcs-fetch-master-state file
(vc-file-getprop file
'vc-workfile-version))))
- (if (eq state 'up-to-date)
- (if (vc-workfile-unchanged-p file)
- 'up-to-date
- 'unlocked-changes)
- state)))
+ (if (not (eq state 'up-to-date))
+ state
+ (require 'vc)
+ (if (vc-workfile-unchanged-p file)
+ 'up-to-date
+ (if (eq (vc-checkout-model file) 'locking)
+ 'unlocked-changes
+ 'edited)))))
(defun vc-rcs-state-heuristic (file)
"State heuristic for RCS."
(unless version (setq version (vc-workfile-version file)))
(with-temp-buffer
(string= version
- (if (vc-rcs-trunk-p version)
+ (if (vc-trunk-p version)
(progn
;; Compare VERSION to the head version number.
(vc-insert-file (vc-name file) "^[0-9]")
;; If we are not on the trunk, we need to examine the
;; whole current branch.
(vc-insert-file (vc-name file) "^desc")
- (vc-rcs-find-most-recent-rev (vc-rcs-branch-part version))))))
+ (vc-rcs-find-most-recent-rev (vc-branch-part version))))))
(defun vc-rcs-checkout-model (file)
"RCS-specific version of `vc-checkout-model'."
Automatically retrieve a read-only version of the file with keywords
expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
(let ((subdir (expand-file-name "RCS" (file-name-directory file)))
- (switches (list
+ (switches (append
(if (stringp vc-register-switches)
(list vc-register-switches)
vc-register-switches)
;; branch accordingly
(cond
((and old-version new-version
- (not (string= (vc-rcs-branch-part old-version)
- (vc-rcs-branch-part new-version))))
+ (not (string= (vc-branch-part old-version)
+ (vc-branch-part new-version))))
(vc-rcs-set-default-branch file
- (if (vc-rcs-trunk-p new-version) nil
- (vc-rcs-branch-part new-version)))
+ (if (vc-trunk-p new-version) nil
+ (vc-branch-part new-version)))
;; If this is an old RCS release, we might have
;; to remove a remaining lock.
(if (not (vc-rcs-release-p "5.6.2"))
(vc-do-command nil 1 "rcs" (vc-name file)
(concat "-u" old-version))))))))
-(defun vc-rcs-checkout (file &optional writable rev workfile)
+(defun vc-rcs-checkout (file &optional editable rev workfile)
"Retrieve a copy of a saved version of FILE into a workfile."
(let ((filename (or workfile file))
(file-buffer (get-file-buffer file))
;; RCS can't check out into arbitrary file names directly.
;; Use `co -p' and make stdout point to the correct file.
(let ((vc-modes (logior (file-modes (vc-name file))
- (if writable 128 0)))
+ (if editable 128 0)))
(failed t))
(unwind-protect
(progn
(apply 'vc-do-command
(current-buffer) 0 "co" (vc-name file)
"-q" ;; suppress diagnostic output
- (if writable "-l")
+ (if editable "-l")
(concat "-p" rev)
switches)))
(set-file-modes filename
(logior (file-modes (vc-name file))
- (if writable 128 0)))
+ (if editable 128 0)))
(setq failed nil))
(and failed (file-exists-p filename)
(delete-file filename))))
;; If locking is not strict, force to overwrite
;; the writable workfile.
(if (eq (vc-checkout-model file) 'implicit) "-f")
- (if writable "-l")
+ (if editable "-l")
(if rev (concat "-r" rev)
;; if no explicit revision was specified,
;; check out that of the working file
(vc-rcs-set-default-branch
file
(if (vc-rcs-latest-on-branch-p file new-version)
- (if (vc-rcs-trunk-p new-version) nil
- (vc-rcs-branch-part new-version))
+ (if (vc-trunk-p new-version) nil
+ (vc-branch-part new-version))
new-version))))))
(message "Checking out %s...done" filename)))))
-(defun vc-rcs-revert (file)
+(defun vc-rcs-revert (file &optional contents-done)
"Revert FILE to the version it was based on."
(vc-do-command nil 0 "co" (vc-name file) "-f"
(concat "-u" (vc-workfile-version file))))
-(defun vc-rcs-cancel-version (file writable)
+(defun vc-rcs-cancel-version (file editable)
"Undo the most recent checkin of FILE.
-WRITABLE non-nil means previous version should be locked."
+EDITABLE non-nil means previous version should be locked."
(let* ((target (vc-workfile-version file))
(previous (if (vc-trunk-p target) "" (vc-branch-part target)))
(config (current-window-configuration))
(condition-case err
(progn
(vc-do-command nil 0 "co" (vc-name file) "-f"
- (concat (if writable "-l" "-u") previous))
+ (concat (if editable "-l" "-u") previous))
(setq done t))
(error (set-buffer "*vc*")
(goto-char (point-min))
(defun vc-rcs-steal-lock (file &optional rev)
"Steal the lock on the current workfile for FILE and revision REV.
Needs RCS 5.6.2 or later for -M."
- (vc-do-command nil 0 "rcs" (vc-name file) "-M"
- (concat "-u" rev) (concat "-l" rev)))
+ (vc-do-command nil 0 "rcs" (vc-name file) "-M" (concat "-u" rev))
+ ;; Do a real checkout after stealing the lock, so that we see
+ ;; expanded headers.
+ (vc-do-command nil 0 "co" (vc-name file) "-f" (concat "-l" rev)))
\f
(defun vc-rcs-print-log (file)
"Get change log associated with FILE."
- (vc-do-command t 0 "rlog" (vc-name file)))
+ (vc-do-command nil 0 "rlog" (vc-name file)))
(defun vc-rcs-show-log-entry (version)
(when (re-search-forward
(defun vc-rcs-diff (file &optional oldvers newvers)
"Get a difference report using RCS between two versions of FILE."
(if (not oldvers) (setq oldvers (vc-workfile-version file)))
- ;; If we know that --brief is not supported, don't try it.
- (let* ((diff-switches-list (if (listp diff-switches)
- diff-switches
- (list diff-switches)))
- (options (append (list "-q"
- (concat "-r" oldvers)
- (and newvers (concat "-r" newvers)))
- diff-switches-list)))
- (apply 'vc-do-command t 1 "rcsdiff" file options)))
+ (apply 'vc-do-command "*vc-diff*" 1 "rcsdiff" file
+ (append (list "-q"
+ (concat "-r" oldvers)
+ (and newvers (concat "-r" newvers)))
+ (vc-diff-switches-list 'RCS))))
\f
;;;
;;; Internal functions
;;;
-(defun vc-rcs-trunk-p (rev)
- "Return t if REV is an RCS revision on the trunk."
- (not (eq nil (string-match "\\`[0-9]+\\.[0-9]+\\'" rev))))
-
-(defun vc-rcs-branch-part (rev)
- "Return the branch part of an RCS revision number REV"
- (substring rev 0 (string-match "\\.[0-9]+\\'" rev)))
-
-(defun vc-rcs-branch-p (rev)
- "Return t if REV is an RCS branch revision"
- (not (eq nil (string-match "\\`[0-9]+\\(\\.[0-9]+\\.[0-9]+\\)*\\'" rev))))
-
-(defun vc-rcs-minor-part (rev)
- "Return the minor version number of an RCS revision number REV."
- (string-match "[0-9]+\\'" rev)
- (substring rev (match-beginning 0) (match-end 0)))
-
-(defun vc-rcs-previous-version (rev)
- "Guess the previous RCS version number"
- (let ((branch (vc-rcs-branch-part rev))
- (minor-num (string-to-number (vc-rcs-minor-part rev))))
- (if (> minor-num 1)
- ;; version does probably not start a branch or release
- (concat branch "." (number-to-string (1- minor-num)))
- (if (vc-rcs-trunk-p rev)
- ;; we are at the beginning of the trunk --
- ;; don't know anything to return here
- ""
- ;; we are at the beginning of a branch --
- ;; return version of starting point
- (vc-rcs-branch-part branch)))))
-
(defun vc-rcs-workfile-is-newer (file)
"Return non-nil if FILE is newer than its RCS master.
This likely means that FILE has been changed with respect
(setq latest-rev rev)
(setq value (match-string 1)))))
(or value
- (vc-rcs-branch-part branch))))
+ (vc-branch-part branch))))
(defun vc-rcs-fetch-master-state (file &optional workfile-version)
"Compute the master file's idea of the state of FILE.
(if (or workfile-is-latest
(vc-rcs-latest-on-branch-p file workfile-version))
;; workfile version is latest on branch
- (if (eq (vc-checkout-model file) 'locking)
- 'up-to-date
- (require 'vc)
- (if (vc-workfile-unchanged-p file)
- 'up-to-date
- 'edited))
+ 'up-to-date
;; workfile version is not latest on branch
'needs-patch))
;; locked by the calling user