Mercurial > emacs
changeset 67574:9c4c9e375003
(vc-default-revert): New fun.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 14 Dec 2005 16:57:35 +0000 |
parents | 123d22825421 |
children | d0f7b15488df |
files | lisp/vc.el |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/vc.el Wed Dec 14 16:56:48 2005 +0000 +++ b/lisp/vc.el Wed Dec 14 16:57:35 2005 +0000 @@ -2529,6 +2529,33 @@ (if (file-exists-p backup-file) backup-file))))) +(defun vc-default-revert (backend file contents-done) + (unless contents-done + (let ((rev (vc-workfile-version file)) + (file-buffer (or (get-file-buffer file) (current-buffer)))) + (message "Checking out %s..." file) + (let ((failed t) + (backup-name (car (find-backup-file-name file)))) + (when backup-name + (copy-file file backup-name 'ok-if-already-exists 'keep-date) + (unless (file-writable-p file) + (set-file-modes file (logior (file-modes file) 128)))) + (unwind-protect + (let ((coding-system-for-read 'no-conversion) + (coding-system-for-write 'no-conversion)) + (with-temp-file file + (let ((outbuf (current-buffer))) + ;; Change buffer to get local value of vc-checkout-switches. + (with-current-buffer file-buffer + (let ((default-directory (file-name-directory file))) + (vc-call find-version file rev outbuf))))) + (setq failed nil)) + (when backup-name + (if failed + (rename-file backup-name file 'ok-if-already-exists) + (and (not vc-make-backup-files) (delete-file backup-name)))))) + (message "Checking out %s...done" file)))) + (defun vc-revert-file (file) "Revert FILE back to the version it was based on." (with-vc-properties