diff options
| author | André Spiegel | 2000-10-22 15:28:58 +0000 |
|---|---|---|
| committer | André Spiegel | 2000-10-22 15:28:58 +0000 |
| commit | e896a9e1dce27c6fcc5dd39a6d0e9c4ff8f52ed2 (patch) | |
| tree | 2828f7b8bfa7a456542d470d8dab9368ba3d494a | |
| parent | d9aef30f820b5b5716375bd93aeaefc566d5936f (diff) | |
| download | emacs-e896a9e1dce27c6fcc5dd39a6d0e9c4ff8f52ed2.tar.gz emacs-e896a9e1dce27c6fcc5dd39a6d0e9c4ff8f52ed2.zip | |
(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.
| -rw-r--r-- | lisp/vc-hooks.el | 41 |
1 files changed, 33 insertions, 8 deletions
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 @@ | |||
| 5 | ;; Author: FSF (see vc.el for full credits) | 5 | ;; Author: FSF (see vc.el for full credits) |
| 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | 6 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> |
| 7 | 7 | ||
| 8 | ;; $Id: vc-hooks.el,v 1.122 2000/10/04 09:50:21 spiegel Exp $ | 8 | ;; $Id: vc-hooks.el,v 1.123 2000/10/05 22:47:21 monnier Exp $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -459,14 +459,40 @@ to do that, use this command a second time with no argument." | |||
| 459 | (toggle-read-only))) | 459 | (toggle-read-only))) |
| 460 | (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) | 460 | (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) |
| 461 | 461 | ||
| 462 | (defun vc-default-make-version-backups (backend file) | 462 | (defun vc-default-make-version-backups-p (backend file) |
| 463 | "Return non-nil if unmodified repository versions should | 463 | "Return non-nil if unmodified repository versions should |
| 464 | be backed up locally. The default is to switch off this feature." | 464 | be backed up locally. The default is to switch off this feature." |
| 465 | nil) | 465 | nil) |
| 466 | 466 | ||
| 467 | (defun vc-version-backup-file-name (file &optional rev) | 467 | (defun vc-version-backup-file-name (file &optional rev manual regexp) |
| 468 | "Return a backup file name for REV or the current version of FILE." | 468 | "Return a backup file name for REV or the current version of FILE. |
| 469 | (concat file ".~" (or rev (vc-workfile-version file)) "~")) | 469 | If MANUAL is non-nil it means that a name for backups created by |
| 470 | the user should be returned; if REGEXP is non-nil that means to return | ||
| 471 | a regexp for matching all such backup files, regardless of the version." | ||
| 472 | (let ((delim (if manual "~" "#"))) | ||
| 473 | (if regexp | ||
| 474 | (concat (regexp-quote (file-name-nondirectory file)) | ||
| 475 | "." delim "[0-9.]+" delim) | ||
| 476 | (expand-file-name (concat (file-name-nondirectory file) | ||
| 477 | "." delim | ||
| 478 | (or rev (vc-workfile-version file)) | ||
| 479 | delim) | ||
| 480 | (file-name-directory file))))) | ||
| 481 | |||
| 482 | (defun vc-delete-automatic-version-backups (file) | ||
| 483 | "Delete all existing automatic version backups for FILE." | ||
| 484 | (mapcar | ||
| 485 | (lambda (f) | ||
| 486 | (delete-file f)) | ||
| 487 | (directory-files (file-name-directory file) t | ||
| 488 | (vc-version-backup-file-name file nil nil t)))) | ||
| 489 | |||
| 490 | (defun vc-make-version-backup (file) | ||
| 491 | "Make a backup copy of FILE, which is assumed in sync with the repository. | ||
| 492 | Before doing that, check if there are any old backups and get rid of them." | ||
| 493 | (vc-delete-automatic-version-backups file) | ||
| 494 | (copy-file file (vc-version-backup-file-name file) | ||
| 495 | nil 'keep-date)) | ||
| 470 | 496 | ||
| 471 | (defun vc-before-save () | 497 | (defun vc-before-save () |
| 472 | "Function to be called by `basic-save-buffer' (in files.el)." | 498 | "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." | |||
| 477 | (and (vc-backend file) | 503 | (and (vc-backend file) |
| 478 | (vc-up-to-date-p file) | 504 | (vc-up-to-date-p file) |
| 479 | (eq (vc-checkout-model file) 'implicit) | 505 | (eq (vc-checkout-model file) 'implicit) |
| 480 | (vc-call make-version-backups file) | 506 | (vc-call make-version-backups-p file) |
| 481 | (copy-file file (vc-version-backup-file-name file) | 507 | (vc-make-version-backup file)))) |
| 482 | 'ok-if-already-exists 'keep-date)))) | ||
| 483 | 508 | ||
| 484 | (defun vc-after-save () | 509 | (defun vc-after-save () |
| 485 | "Function to be called by `basic-save-buffer' (in files.el)." | 510 | "Function to be called by `basic-save-buffer' (in files.el)." |