Function: cvs-retrieve-revision
cvs-retrieve-revision is a byte-compiled function defined in
pcvs.el.gz.
Signature
(cvs-retrieve-revision FILEINFO REV)
Documentation
Retrieve the given REVision of the file in FILEINFO into a new buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/vc/pcvs.el.gz
;;
;; Interactive merge/diff support.
;;
(defun cvs-retrieve-revision (fileinfo rev)
"Retrieve the given REVision of the file in FILEINFO into a new buffer."
(let* ((file (cvs-fileinfo->full-name fileinfo))
(buffile (concat file "." rev)))
(or (find-buffer-visiting buffile)
(with-current-buffer (create-file-buffer buffile)
(message "Retrieving revision %s..." rev)
;; Discard stderr output to work around the CVS+SSH+libc
;; problem when stdout and stderr are the same.
(let ((res
(let ((coding-system-for-read 'binary))
(apply 'process-file cvs-program nil '(t nil) nil
"-q" "update" "-p"
;; If `rev' is HEAD, don't pass it at all:
;; the default behavior is to get the head
;; of the current branch whereas "-r HEAD"
;; stupidly gives you the head of the trunk.
(append (unless (equal rev "HEAD") (list "-r" rev))
(list file))))))
(when (and res (not (and (equal 0 res))))
(error "Something went wrong retrieving revision %s: %s" rev res))
;; Figure out the encoding used and decode the byte-sequence
;; into a sequence of chars.
(decode-coding-inserted-region
(point-min) (point-max) file t nil nil t)
;; Set buffer-file-coding-system.
(after-insert-file-set-coding (buffer-size) t)
(set-buffer-modified-p nil)
(let ((buffer-file-name (expand-file-name file)))
(after-find-file))
(setq buffer-read-only t)
(message "Retrieving revision %s... Done" rev)
(current-buffer))))))