# HG changeset patch # User Andr Spiegel # Date 974388580 0 # Node ID 8a998774febc998e9c29803c605dd5fc02f71ca8 # Parent 714a4c4917cdb9610aaa63dbce30903274cd9835 (vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on. (vc-cvs-checkout): When this is used for reverting the workfile, make a backup of the original contents and revert to that in case of error. diff -r 714a4c4917cd -r 8a998774febc lisp/vc-cvs.el --- a/lisp/vc-cvs.el Thu Nov 16 15:26:37 2000 +0000 +++ b/lisp/vc-cvs.el Thu Nov 16 15:29:40 2000 +0000 @@ -5,7 +5,7 @@ ;; Author: FSF (see vc.el for full credits) ;; Maintainer: Andre Spiegel -;; $Id: vc-cvs.el,v 1.8 2000/10/27 15:06:27 spiegel Exp $ +;; $Id: vc-cvs.el,v 1.9 2000/11/16 13:38:03 spiegel Exp $ ;; This file is part of GNU Emacs. @@ -472,7 +472,8 @@ (vc-cvs-checkout file nil (vc-workfile-version file) file) ;; If "cvs edit" was used to make the file writable, ;; call "cvs unedit" now to undo that. - (if (not (eq (vc-cvs-checkout-model file) 'implicit)) + (if (and (not (eq (vc-cvs-checkout-model file) 'implicit)) + vc-cvs-use-edit) (vc-do-command nil 0 "cvs" file "unedit"))) (defun vc-cvs-diff (file &optional oldvers newvers) @@ -607,7 +608,15 @@ ;; the file in the right place. (setq default-directory (file-name-directory filename)) (if workfile - (let ((failed t)) + (let ((failed t) + (backup-name (if (string= filename workfile) + (car (find-backup-file-name filename))))) + (when backup-name + (copy-file filename backup-name + 'ok-if-already-exists 'keep-date) + (unless (file-writable-p filename) + (set-file-modes filename + (logior (file-modes filename) 128)))) (unwind-protect (progn (let ((coding-system-for-read 'no-conversion) @@ -622,7 +631,15 @@ "-p" switches))) (setq failed nil)) - (and failed (file-exists-p filename) (delete-file filename)))) + (if failed + (if backup-name + (rename-file backup-name filename + 'ok-if-already-exists) + (if (file-exists-p filename) + (delete-file filename))) + (and backup-name + (not vc-make-backup-files) + (delete-file backup-name))))) (if (and (file-exists-p file) (not rev)) ;; If no revision was specified, just make the file writable ;; if necessary (using `cvs-edit' if requested).