diff options
| author | André Spiegel | 2000-09-21 13:21:41 +0000 |
|---|---|---|
| committer | André Spiegel | 2000-09-21 13:21:41 +0000 |
| commit | 0db2c43cde648cc9a8608586b0b49c840c3ffd66 (patch) | |
| tree | e74f7c2f3d6d39cfae56b77fd6f57e35eb5d9156 | |
| parent | 64341022ab59a4a65c1f0a9512ab309a255c2046 (diff) | |
| download | emacs-0db2c43cde648cc9a8608586b0b49c840c3ffd66.tar.gz emacs-0db2c43cde648cc9a8608586b0b49c840c3ffd66.zip | |
(vc-rcs-workfile-is-newer): New function.
(vc-rcs-state-heuristic): Use it to guess the state of files with
non-strict locking.
(vc-rcs-find-most-recent-rev): Handle the case when a branch has been
set with -b, but not created yet.
(vc-rcs-fetch-master-state): With non-strict locking, compare file
contents in order to find the state.
(vc-rcs-checkin): Allow creation of branches with no changes.
(vc-rcs-unregister, vc-rcs-receive-file,
vc-rcs-set-non-strict-locking): New functions.
| -rw-r--r-- | lisp/vc-rcs.el | 97 |
1 files changed, 90 insertions, 7 deletions
diff --git a/lisp/vc-rcs.el b/lisp/vc-rcs.el index 2cc42744dc4..758b8ce628c 100644 --- a/lisp/vc-rcs.el +++ b/lisp/vc-rcs.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-rcs.el,v 1.3 2000/09/07 20:02:38 fx Exp $ | 8 | ;; $Id: vc-rcs.el,v 1.4 2000/09/09 00:48:40 monnier Exp $ |
| 9 | 9 | ||
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | 11 | ||
| @@ -132,7 +132,11 @@ For a description of possible values, see `vc-check-master-templates'." | |||
| 132 | (not (vc-mistrust-permissions file))) | 132 | (not (vc-mistrust-permissions file))) |
| 133 | (cond | 133 | (cond |
| 134 | ((string-match ".rw..-..-." (nth 8 (file-attributes file))) | 134 | ((string-match ".rw..-..-." (nth 8 (file-attributes file))) |
| 135 | (vc-file-setprop file 'vc-checkout-model 'implicit)) | 135 | (vc-file-setprop file 'vc-checkout-model 'implicit) |
| 136 | (setq state | ||
| 137 | (if (vc-rcs-workfile-is-newer file) | ||
| 138 | 'edited | ||
| 139 | 'up-to-date))) | ||
| 136 | ((string-match ".r-..-..-." (nth 8 (file-attributes file))) | 140 | ((string-match ".r-..-..-." (nth 8 (file-attributes file))) |
| 137 | (vc-file-setprop file 'vc-checkout-model 'locking)))) | 141 | (vc-file-setprop file 'vc-checkout-model 'locking)))) |
| 138 | state) | 142 | state) |
| @@ -144,15 +148,29 @@ For a description of possible values, see `vc-check-master-templates'." | |||
| 144 | (vc-file-setprop file 'vc-checkout-model 'locking) | 148 | (vc-file-setprop file 'vc-checkout-model 'locking) |
| 145 | 'up-to-date) | 149 | 'up-to-date) |
| 146 | ((string-match ".rw..-..-." permissions) | 150 | ((string-match ".rw..-..-." permissions) |
| 147 | (if (file-ownership-preserved-p file) | 151 | (if (eq (vc-checkout-model file) 'locking) |
| 148 | 'edited | 152 | (if (file-ownership-preserved-p file) |
| 149 | (vc-user-login-name owner-uid))) | 153 | 'edited |
| 154 | (vc-user-login-name owner-uid)) | ||
| 155 | (if (vc-rcs-workfile-is-newer file) | ||
| 156 | 'edited | ||
| 157 | 'up-to-date))) | ||
| 150 | (t | 158 | (t |
| 151 | ;; Strange permissions. Fall through to | 159 | ;; Strange permissions. Fall through to |
| 152 | ;; expensive state computation. | 160 | ;; expensive state computation. |
| 153 | (vc-rcs-state file)))) | 161 | (vc-rcs-state file)))) |
| 154 | (vc-rcs-state file))))) | 162 | (vc-rcs-state file))))) |
| 155 | 163 | ||
| 164 | (defun vc-rcs-workfile-is-newer (file) | ||
| 165 | "Return non-nil if FILE is newer than its RCS master. | ||
| 166 | This likely means that FILE has been changed with respect | ||
| 167 | to its master version." | ||
| 168 | (let ((file-time (nth 5 (file-attributes file))) | ||
| 169 | (master-time (nth 5 (file-attributes (vc-name file))))) | ||
| 170 | (or (> (nth 0 file-time) (nth 0 master-time)) | ||
| 171 | (and (= (nth 0 file-time) (nth 0 master-time)) | ||
| 172 | (> (nth 1 file-time) (nth 1 master-time)))))) | ||
| 173 | |||
| 156 | (defun vc-rcs-workfile-version (file) | 174 | (defun vc-rcs-workfile-version (file) |
| 157 | "RCS-specific version of `vc-workfile-version'." | 175 | "RCS-specific version of `vc-workfile-version'." |
| 158 | (or (and vc-consult-headers | 176 | (or (and vc-consult-headers |
| @@ -182,7 +200,8 @@ For a description of possible values, see `vc-check-master-templates'." | |||
| 182 | (when (< latest-rev rev) | 200 | (when (< latest-rev rev) |
| 183 | (setq latest-rev rev) | 201 | (setq latest-rev rev) |
| 184 | (setq value (match-string 1))))) | 202 | (setq value (match-string 1))))) |
| 185 | value)) | 203 | (or value |
| 204 | (vc-rcs-branch-part branch)))) | ||
| 186 | 205 | ||
| 187 | (defun vc-rcs-fetch-master-state (file &optional workfile-version) | 206 | (defun vc-rcs-fetch-master-state (file &optional workfile-version) |
| 188 | "Compute the master file's idea of the state of FILE. | 207 | "Compute the master file's idea of the state of FILE. |
| @@ -234,7 +253,12 @@ file." | |||
| 234 | (if (or workfile-is-latest | 253 | (if (or workfile-is-latest |
| 235 | (vc-rcs-latest-on-branch-p file workfile-version)) | 254 | (vc-rcs-latest-on-branch-p file workfile-version)) |
| 236 | ;; workfile version is latest on branch | 255 | ;; workfile version is latest on branch |
| 237 | 'up-to-date | 256 | (if (eq (vc-checkout-model file) 'locking) |
| 257 | 'up-to-date | ||
| 258 | (require 'vc) | ||
| 259 | (if (vc-workfile-unchanged-p file) | ||
| 260 | 'up-to-date | ||
| 261 | 'edited)) | ||
| 238 | ;; workfile version is not latest on branch | 262 | ;; workfile version is not latest on branch |
| 239 | 'needs-patch)) | 263 | 'needs-patch)) |
| 240 | ;; locked by the calling user | 264 | ;; locked by the calling user |
| @@ -565,6 +589,10 @@ CVS releases are handled reasonably, too \(1.3 < 1.4* < 1.5\)." | |||
| 565 | (and (vc-rcs-release-p "5.6.4") "-j") | 589 | (and (vc-rcs-release-p "5.6.4") "-j") |
| 566 | (concat (if vc-keep-workfiles "-u" "-r") rev) | 590 | (concat (if vc-keep-workfiles "-u" "-r") rev) |
| 567 | (concat "-m" comment) | 591 | (concat "-m" comment) |
| 592 | ;; allow creation of branches with no changes; | ||
| 593 | ;; this is used by vc-rcs-receive-file if the | ||
| 594 | ;; base version cannot be found | ||
| 595 | (if (string-match ".1.1$" rev) "-f") | ||
| 568 | switches) | 596 | switches) |
| 569 | (vc-file-setprop file 'vc-workfile-version nil) | 597 | (vc-file-setprop file 'vc-workfile-version nil) |
| 570 | 598 | ||
| @@ -680,6 +708,61 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile." | |||
| 680 | nil t) | 708 | nil t) |
| 681 | (match-string 1)))))) | 709 | (match-string 1)))))) |
| 682 | 710 | ||
| 711 | (defun vc-rcs-unregister (file) | ||
| 712 | "Unregister FILE from RCS. | ||
| 713 | If this leaves the RCS subdirectory empty, ask the user | ||
| 714 | whether to remove it." | ||
| 715 | (let* ((master (vc-name file)) | ||
| 716 | (dir (file-name-directory master))) | ||
| 717 | (delete-file master) | ||
| 718 | (and (string= (file-name-nondirectory (directory-file-name dir)) "RCS") | ||
| 719 | ;; check whether RCS dir is empty, i.e. it does not | ||
| 720 | ;; contain any files except "." and ".." | ||
| 721 | (not (directory-files dir nil | ||
| 722 | "^\\([^.]\\|\\.[^.]\\|\\.\\.[^.]\\).*")) | ||
| 723 | (yes-or-no-p (format "Directory %s is empty; remove it? " dir)) | ||
| 724 | (delete-directory dir)))) | ||
| 725 | |||
| 726 | (defun vc-rcs-receive-file (file move) | ||
| 727 | "Implementation of receive-file for RCS." | ||
| 728 | (let ((old-backend (vc-backend file)) | ||
| 729 | (rev (vc-workfile-version file)) | ||
| 730 | (state (vc-state file)) | ||
| 731 | (checkout-model (vc-checkout-model file)) | ||
| 732 | (comment (and move | ||
| 733 | (vc-find-backend-function old-backend 'comment-history) | ||
| 734 | (vc-call 'comment-history file)))) | ||
| 735 | (if move (vc-unregister file old-backend)) | ||
| 736 | (vc-file-clearprops file) | ||
| 737 | (if (not (vc-rcs-registered file)) | ||
| 738 | (progn | ||
| 739 | (with-vc-properties | ||
| 740 | file | ||
| 741 | ;; TODO: If the file was 'edited under the old backend, | ||
| 742 | ;; this should actually register the version | ||
| 743 | ;; it was based on. | ||
| 744 | (vc-rcs-register file rev "") | ||
| 745 | `((vc-backend ,backend))) | ||
| 746 | (if (eq checkout-model 'implicit) | ||
| 747 | (vc-rcs-set-non-strict-locking file)) | ||
| 748 | (if (not move) | ||
| 749 | (vc-do-command nil 0 "rcs" file (concat "-b" rev ".1")))) | ||
| 750 | (vc-file-setprop file 'vc-backend backend) | ||
| 751 | (vc-file-setprop file 'vc-state 'edited) | ||
| 752 | (set-file-modes file | ||
| 753 | (logior (file-modes file) 128))) | ||
| 754 | (when (or move (eq state 'edited)) | ||
| 755 | (vc-file-setprop file 'vc-state 'edited) | ||
| 756 | ;; TODO: The comment history should actually become the | ||
| 757 | ;; initial contents of the log entry buffer. | ||
| 758 | (and comment (ring-insert vc-comment-ring comment)) | ||
| 759 | (vc-checkin file (concat rev ".1.1"))))) | ||
| 760 | |||
| 761 | (defun vc-rcs-set-non-strict-locking (file) | ||
| 762 | (vc-do-command nil 0 "rcs" file "-U") | ||
| 763 | (vc-file-setprop file 'vc-checkout-model 'implicit) | ||
| 764 | (set-file-modes file (logior (file-modes file) 128))) | ||
| 765 | |||
| 683 | (defun vc-rcs-checkout (file &optional writable rev workfile) | 766 | (defun vc-rcs-checkout (file &optional writable rev workfile) |
| 684 | "Retrieve a copy of a saved version of FILE into a workfile." | 767 | "Retrieve a copy of a saved version of FILE into a workfile." |
| 685 | (let ((filename (or workfile file)) | 768 | (let ((filename (or workfile file)) |