From: Stefan Monnier Date: Wed, 14 Dec 2005 16:57:35 +0000 (+0000) Subject: (vc-default-revert): New fun. X-Git-Tag: emacs-pretest-22.0.90~5280 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d49e540c484c3f87be3d414abde99dd50ce37f45;p=emacs.git (vc-default-revert): New fun. --- diff --git a/lisp/vc.el b/lisp/vc.el index 4087c67a4f0..9429ab4c646 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -2529,6 +2529,33 @@ return its name; otherwise return nil." (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