EmacsWiki: Revision Control System (original) (raw)
RCS is the simplest thing that does the job. It provides VersionControl to files on a per-file basis. You don’t have to do anything special in order to use it in Emacs. Just issue the keyboard sequence of ‘C-x v v’
to get started.
- To put a file under VersionControl with RCS type
‘C-x v v’
(‘vc-next-action’
). - After making edits,
- view the changes with `C-x v =’ (
‘vc-diff’
). - or check in the revision by typing another
‘C-x v v’
.- After entering a log message, complete the check-in with
‘C-c C-c’
(‘vc-finish-logentry’
).
- After entering a log message, complete the check-in with
- Instead of checking in, undo your changes with
‘C-x v u’
(‘vc-revert-buffer’
).
- view the changes with `C-x v =’ (
- At any moment,
- view a file’s revision log with
‘C-x v l’
(‘vc-print-log’
). - be prompted for another version number to view the file in another window with `C-x v ~’ (
‘vc-version-other-window’
).
- view a file’s revision log with
Automatically check in/out
To automatically check in/out a file when saving it if the file is under RCS, put this in your .emacs:
(defun rcs-ci-co nil "check in check out the file if it is under vc with rcs with a prefix other than 1 only check-in" (when (eq (vc-backend (buffer-file-name)) 'RCS) (if (= args 1) (save-window-excursion (vc-toggle-read-only) (call-interactively 'log-edit-done) (vc-toggle-read-only)) (vc-toggle-read-only))))
(add-hook 'after-save-hook 'rcs-ci-co)
(defun my-vc-diff (historic &optional not-urgent) "my vc diff, same as vc-diff but in case of rcs, display the diffs between current version and previous one (with a prefix calls vc-diff)" (interactive (list current-prefix-arg t)) (let ((file (buffer-file-name))) (if historic (call-interactively 'vc-version-diff) (if (eq (vc-backend file) 'RCS) (vc-version-diff file (vc-previous-version (vc-workfile-version file)) (vc-workfile-version file)) (call-interactively 'vc-diff)))))
(global-set-key (kbd "C-x v=") 'my-vc-diff)
Note that if a prefix is used when saving the file, the file is only checked in allowing you to put a meaningful message to the Changelog.
it didn’t work for me (the first defun threw errors), but this other did the trick
(defun rcs-ci-co nil "check in check out the file if it is under vc with rcs" (when (eq (vc-backend (buffer-file-name)) 'RCS) (progn (vc-checkin (list (buffer-file-name)) 'RCS nil "saved" nil) (vc-checkout (buffer-file-name) t) )))
(add-hook 'after-save-hook 'rcs-ci-co)
but it has problems anyway, for example: vc-checkin first tries to save, which is a problem when you want to create another major version. There is also a nice discussion here: VersionControlAlways – AlvaroMartinez
Starting with Emacs 22 (in earlier versions the vc-rcs-*-switches were present, but ignored by the functions) you can also just use
(setq vc-rcs-checkin-switches "-l")
This means use “ci -l file” to check out a locked (writable) version right after the check-in. This should always be fine when using RCS.
Modifiable Log View
Like WDired, it would be handy if you could hand-edit the contents of log view (revision logs, dates, author, state, file description) and commit the changes to the RCS file. Yet another WishList item.
Related Information
- GNU RCS Home Page
Resources on Using GNU RCS by Aaron HawleyArchived version- Win32 Port
- The Joys of RCS - a nice writeup about version control/emacs/RCS.