diff options
| author | André Spiegel | 1995-08-18 20:22:53 +0000 |
|---|---|---|
| committer | André Spiegel | 1995-08-18 20:22:53 +0000 |
| commit | 04446ed0c2cd9c5e4cfcac0e3be5bb49090762fb (patch) | |
| tree | e5d75ba625083cf0dda5b8de1b94327a20b4ca1f | |
| parent | 361b7640072e3c34e68a11f9f8765bd8716c3529 (diff) | |
| download | emacs-04446ed0c2cd9c5e4cfcac0e3be5bb49090762fb.tar.gz emacs-04446ed0c2cd9c5e4cfcac0e3be5bb49090762fb.zip | |
(vc-fetch-master-properties): Recognize cvs status "Unresolved Conflict".
(vc-locking-user): Count cvs status `unresolved-conflict' as "locked".
(vc-checkout-model): New property and access function (still simplistic).
(vc-after-save-hook): New function.
(vc-mode-line): When the file is locked by somebody else, make the
buffer read-only. (Formerly this was only done for root.) Don't
write-protect the buffer if the file is unlocked. Instead, install
vc-after-save-hook, which "locks" the file when modifications are
saved.
| -rw-r--r-- | lisp/vc-hooks.el | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 9b01ea0fc9d..b55e286ebee 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el | |||
| @@ -319,6 +319,8 @@ value of this flag.") | |||
| 319 | (vc-file-setprop file 'vc-cvs-status 'needs-merge)) | 319 | (vc-file-setprop file 'vc-cvs-status 'needs-merge)) |
| 320 | ((string-match "Needs Checkout" status) | 320 | ((string-match "Needs Checkout" status) |
| 321 | (vc-file-setprop file 'vc-cvs-status 'needs-checkout)) | 321 | (vc-file-setprop file 'vc-cvs-status 'needs-checkout)) |
| 322 | ((string-match "Unresolved Conflict" status) | ||
| 323 | (vc-file-setprop file 'vc-cvs-status 'unresolved-conflict)) | ||
| 322 | (t (vc-file-setprop file 'vc-cvs-status nil)))))) | 324 | (t (vc-file-setprop file 'vc-cvs-status nil)))))) |
| 323 | (if (get-buffer "*vc-info*") | 325 | (if (get-buffer "*vc-info*") |
| 324 | (kill-buffer (get-buffer "*vc-info*"))))) | 326 | (kill-buffer (get-buffer "*vc-info*"))))) |
| @@ -447,6 +449,16 @@ value of this flag.") | |||
| 447 | (vc-file-setprop file 'vc-name (car name-and-type)) | 449 | (vc-file-setprop file 'vc-name (car name-and-type)) |
| 448 | (vc-file-setprop file 'vc-backend (cdr name-and-type)))))))) | 450 | (vc-file-setprop file 'vc-backend (cdr name-and-type)))))))) |
| 449 | 451 | ||
| 452 | (defun vc-checkout-model (file) | ||
| 453 | ;; Return `manual' if the user has to type C-x C-q to check out FILE. | ||
| 454 | ;; Return `automatic' if the file can be modified without locking it first. | ||
| 455 | ;; Simplistic version, only returns the default for each backend. | ||
| 456 | (cond ((vc-file-getprop file 'vc-checkout-model)) | ||
| 457 | ((vc-file-setprop file 'vc-checkout-model | ||
| 458 | (cond ((eq (vc-backend file) 'SCCS) 'manual) | ||
| 459 | ((eq (vc-backend file) 'RCS) 'manual) | ||
| 460 | ((eq (vc-backend file) 'CVS) 'automatic)))))) | ||
| 461 | |||
| 450 | ;;; properties indicating the locking state | 462 | ;;; properties indicating the locking state |
| 451 | 463 | ||
| 452 | (defun vc-cvs-status (file) | 464 | (defun vc-cvs-status (file) |
| @@ -495,7 +507,8 @@ value of this flag.") | |||
| 495 | ;; in the CVS case, check the status | 507 | ;; in the CVS case, check the status |
| 496 | ((eq (vc-backend file) 'CVS) | 508 | ((eq (vc-backend file) 'CVS) |
| 497 | (if (and (not (eq (vc-cvs-status file) 'locally-modified)) | 509 | (if (and (not (eq (vc-cvs-status file) 'locally-modified)) |
| 498 | (not (eq (vc-cvs-status file) 'needs-merge))) | 510 | (not (eq (vc-cvs-status file) 'needs-merge)) |
| 511 | (not (eq (vc-cvs-status file) 'unresolved-conflict))) | ||
| 499 | (vc-file-setprop file 'vc-locking-user 'none) | 512 | (vc-file-setprop file 'vc-locking-user 'none) |
| 500 | ;; The expression below should return the username of the owner | 513 | ;; The expression below should return the username of the owner |
| 501 | ;; of the file. It doesn't. It returns the username if it is | 514 | ;; of the file. It doesn't. It returns the username if it is |
| @@ -722,6 +735,12 @@ of the buffer. With prefix argument, ask for version number." | |||
| 722 | (toggle-read-only))) | 735 | (toggle-read-only))) |
| 723 | (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) | 736 | (define-key global-map "\C-x\C-q" 'vc-toggle-read-only) |
| 724 | 737 | ||
| 738 | (defun vc-after-save-hook () | ||
| 739 | ;; Mark the file in the current buffer as "locked" by the user. | ||
| 740 | (remove-hook 'after-save-hook 'vc-after-save-hook t) | ||
| 741 | (vc-file-setprop (buffer-file-name) 'vc-locking-user (user-login-name)) | ||
| 742 | (vc-mode-line (buffer-file-name))) | ||
| 743 | |||
| 725 | (defun vc-mode-line (file &optional label) | 744 | (defun vc-mode-line (file &optional label) |
| 726 | "Set `vc-mode' to display type of version control for FILE. | 745 | "Set `vc-mode' to display type of version control for FILE. |
| 727 | The value is set in the current buffer, which should be the buffer | 746 | The value is set in the current buffer, which should be the buffer |
| @@ -735,16 +754,19 @@ control system name." | |||
| 735 | (and vc-display-status (vc-status file))))) | 754 | (and vc-display-status (vc-status file))))) |
| 736 | (and vc-type | 755 | (and vc-type |
| 737 | (equal file (buffer-file-name)) | 756 | (equal file (buffer-file-name)) |
| 738 | ;; Make the buffer read-only if the file is not locked | 757 | (if (vc-locking-user file) |
| 739 | ;; (or unchanged, in the CVS case). | 758 | ;; If the file is locked by some other user, make |
| 740 | (if (not (vc-locking-user file)) | 759 | ;; the buffer read-only. Like this, even root |
| 741 | (setq buffer-read-only t)) | 760 | ;; cannot modify a file without locking it first. |
| 742 | ;; Even root shouldn't modify a registered file without | 761 | (if (not (string= (user-login-name) (vc-locking-user file))) |
| 743 | ;; locking it first. | 762 | (setq buffer-read-only t)) |
| 744 | (not buffer-read-only) | 763 | ;; If the file is not locked, and vc-checkout-model is |
| 745 | (zerop (user-uid)) | 764 | ;; `automatic', install a hook that will make the file |
| 746 | (not (equal (user-login-name) (vc-locking-user file))) | 765 | ;; "locked" when the buffer is saved. |
| 747 | (setq buffer-read-only t)) | 766 | (cond ((eq (vc-checkout-model file) 'automatic) |
| 767 | (make-local-variable 'after-save-hook) | ||
| 768 | (make-local-hook 'after-save-hook) | ||
| 769 | (add-hook 'after-save-hook 'vc-after-save-hook t))))) | ||
| 748 | (force-mode-line-update) | 770 | (force-mode-line-update) |
| 749 | ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18 | 771 | ;;(set-buffer-modified-p (buffer-modified-p)) ;;use this if Emacs 18 |
| 750 | vc-type)) | 772 | vc-type)) |