From: André Spiegel Date: Sun, 22 Oct 2000 15:28:58 +0000 (+0000) Subject: (vc-version-backup-file-name): New optional args MANUAL and REGEXP. X-Git-Tag: emacs-pretest-21.0.90~684 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e896a9e1dce27c6fcc5dd39a6d0e9c4ff8f52ed2;p=emacs.git (vc-version-backup-file-name): New optional args MANUAL and REGEXP. (vc-delete-automatic-version-backups, vc-make-version-backup): New functions. (vc-before-save): Use the latter. (vc-default-make-version-backups-p): Added `-p' suffix to avoid confusion. --- diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index af08aa6a7d3..b93c3198c25 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -5,7 +5,7 @@ ;; Author: FSF (see vc.el for full credits) ;; Maintainer: Andre Spiegel -;; $Id: vc-hooks.el,v 1.122 2000/10/04 09:50:21 spiegel Exp $ +;; $Id: vc-hooks.el,v 1.123 2000/10/05 22:47:21 monnier Exp $ ;; This file is part of GNU Emacs. @@ -459,14 +459,40 @@ to do that, use this command a second time with no argument." (toggle-read-only))) (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) -(defun vc-default-make-version-backups (backend file) +(defun vc-default-make-version-backups-p (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-version-backup-file-name (file &optional rev manual regexp) + "Return a backup file name for REV or the current version of FILE. +If MANUAL is non-nil it means that a name for backups created by +the user should be returned; if REGEXP is non-nil that means to return +a regexp for matching all such backup files, regardless of the version." + (let ((delim (if manual "~" "#"))) + (if regexp + (concat (regexp-quote (file-name-nondirectory file)) + "." delim "[0-9.]+" delim) + (expand-file-name (concat (file-name-nondirectory file) + "." delim + (or rev (vc-workfile-version file)) + delim) + (file-name-directory file))))) + +(defun vc-delete-automatic-version-backups (file) + "Delete all existing automatic version backups for FILE." + (mapcar + (lambda (f) + (delete-file f)) + (directory-files (file-name-directory file) t + (vc-version-backup-file-name file nil nil t)))) + +(defun vc-make-version-backup (file) + "Make a backup copy of FILE, which is assumed in sync with the repository. +Before doing that, check if there are any old backups and get rid of them." + (vc-delete-automatic-version-backups file) + (copy-file file (vc-version-backup-file-name file) + nil 'keep-date)) (defun vc-before-save () "Function to be called by `basic-save-buffer' (in files.el)." @@ -477,9 +503,8 @@ be backed up locally. The default is to switch off this feature." (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)))) + (vc-call make-version-backups-p file) + (vc-make-version-backup file)))) (defun vc-after-save () "Function to be called by `basic-save-buffer' (in files.el)."