From: André Spiegel Date: Thu, 16 Nov 2000 15:29:40 +0000 (+0000) Subject: (vc-cvs-revert): Use `cvs unedit' only if `vc-cvs-use-edit' is on. X-Git-Tag: emacs-pretest-21.0.90~19 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a8b6979f53afebdbe8b8362f4a0793faaa0e525d;p=emacs.git (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 --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index 6b2ac473806..25b85c88a34 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el @@ -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 @@ Inappropriate for CVS" (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 @@ REV is the revision to check out into WORKFILE." ;; 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 @@ REV is the revision to check out into WORKFILE." "-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).