changeset 32127:1543b0fc904b

(vc-before-save, vc-default-make-version-backups, vc-version-backup-file-name): New functions.
author André Spiegel <spiegel@gnu.org>
date Wed, 04 Oct 2000 09:50:21 +0000
parents 3aab429d3c8a
children f5ee1a4a371c
files lisp/vc-hooks.el
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/vc-hooks.el	Wed Oct 04 09:48:37 2000 +0000
+++ b/lisp/vc-hooks.el	Wed Oct 04 09:50:21 2000 +0000
@@ -5,7 +5,7 @@
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
 
-;; $Id: vc-hooks.el,v 1.120 2000/09/21 13:15:26 spiegel Exp $
+;; $Id: vc-hooks.el,v 1.121 2000/10/02 12:02:37 spiegel Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -459,6 +459,28 @@
     (toggle-read-only)))
 (define-key global-map "\C-x\C-q" 'vc-toggle-read-only)
 
+(defun vc-default-make-version-backups (backend file)
+  "Return non-nil if unmodified repository versions should 
+be backed up locally.  The default is to switch off this feature."
+  nil)
+
+(defun vc-version-backup-file-name (file &optional rev)
+  "Return a backup file name for REV or the current version of FILE."
+  (concat file ".~" (or rev (vc-workfile-version file)) "~"))
+
+(defun vc-before-save ()
+  "Function to be called by `basic-save-buffer' (in files.el)."
+  ;; If the file on disk is still in sync with the repository,
+  ;; and version backups should be made, copy the file to
+  ;; another name.  This enables local diffs and local reverting.
+  (let ((file (buffer-file-name)))
+    (and (vc-backend file)
+	 (vc-up-to-date-p file)
+	 (eq (vc-checkout-model file) 'implicit)
+	 (vc-call make-version-backups file)
+	 (copy-file file (vc-version-backup-file-name file) 
+		    'ok-if-already-exists 'keep-date))))
+
 (defun vc-after-save ()
   "Function to be called by `basic-save-buffer' (in files.el)."
   ;; If the file in the current buffer is under version control,