aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Spiegel2000-09-21 13:27:08 +0000
committerAndré Spiegel2000-09-21 13:27:08 +0000
commit1d502d5a5ae9d7bb3b4710fbc1bffe14f43f9ae2 (patch)
tree0a520f906a52754349b3fe3d9f8dd2b648fa7588
parent0db2c43cde648cc9a8608586b0b49c840c3ffd66 (diff)
downloademacs-1d502d5a5ae9d7bb3b4710fbc1bffe14f43f9ae2.tar.gz
emacs-1d502d5a5ae9d7bb3b4710fbc1bffe14f43f9ae2.zip
(vc-index-of, vc-transfer-file, vc-default-receive-file): New functions.
(vc-next-action-on-file): Call vc-transfer-file at appropriate places. (vc-switch-backend): New function. (vc-prefix-map): Bind `vc-switch-backend' to `b'. (vc-register): Fix prompt. (vc-unregister, vc-default-unregister): New functions. (vc-version-diff): Handle empty buffer in sentinel.
-rw-r--r--lisp/vc.el116
1 files changed, 107 insertions, 9 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index 836495f5899..b298831cb1b 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -73,8 +73,7 @@
73;;;;;;;;;;;;;;;;; Backend-specific functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 73;;;;;;;;;;;;;;;;; Backend-specific functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
74;; 74;;
75;; for each operation FUN, the backend should provide a function vc-BACKEND-FUN. 75;; for each operation FUN, the backend should provide a function vc-BACKEND-FUN.
76;; Operations marked with a `-' instead of a `*' have a sensible default 76;; Operations marked with a `-' instead of a `*' are optional.
77;; behavior.
78 77
79;; * registered (file) 78;; * registered (file)
80;; * state (file) 79;; * state (file)
@@ -91,6 +90,8 @@
91;; - steal-lock (file &optional version) 90;; - steal-lock (file &optional version)
92;; Only required if files can be locked by somebody else. 91;; Only required if files can be locked by somebody else.
93;; * register (file rev comment) 92;; * register (file rev comment)
93;; * unregister (file backend)
94;; - receive-file (file move)
94;; - responsible-p (file) 95;; - responsible-p (file)
95;; Should also work if FILE is a directory (ends with a slash). 96;; Should also work if FILE is a directory (ends with a slash).
96;; - could-register (file) 97;; - could-register (file)
@@ -135,6 +136,7 @@
135;; * print-log (file) 136;; * print-log (file)
136;; Insert the revision log of FILE into the current buffer. 137;; Insert the revision log of FILE into the current buffer.
137;; - show-log-entry (version) 138;; - show-log-entry (version)
139;; - comment-history (file)
138;; - update-changelog (files) 140;; - update-changelog (files)
139;; Find changelog entries for FILES, or for all files at or below 141;; Find changelog entries for FILES, or for all files at or below
140;; the default-directory if FILES is nil. 142;; the default-directory if FILES is nil.
@@ -372,6 +374,7 @@ and that its contents match what the master file says."
372(defvar vc-prefix-map 374(defvar vc-prefix-map
373 (let ((map (make-sparse-keymap))) 375 (let ((map (make-sparse-keymap)))
374 (define-key map "a" 'vc-update-change-log) 376 (define-key map "a" 'vc-update-change-log)
377 (define-key map "b" 'vc-switch-backend)
375 (define-key map "c" 'vc-cancel-version) 378 (define-key map "c" 'vc-cancel-version)
376 (define-key map "d" 'vc-directory) 379 (define-key map "d" 'vc-directory)
377 (define-key map "g" 'vc-annotate) 380 (define-key map "g" 'vc-annotate)
@@ -833,6 +836,7 @@ If VERBOSE is non-nil, query the user rather than using default parameters."
833 (if (not (vc-registered file)) 836 (if (not (vc-registered file))
834 (vc-register verbose comment) 837 (vc-register verbose comment)
835 (vc-recompute-state file) 838 (vc-recompute-state file)
839 (vc-mode-line file)
836 (setq state (vc-state file)) 840 (setq state (vc-state file))
837 (cond 841 (cond
838 ;; up-to-date 842 ;; up-to-date
@@ -841,8 +845,13 @@ If VERBOSE is non-nil, query the user rather than using default parameters."
841 (cond 845 (cond
842 (verbose 846 (verbose
843 ;; go to a different version 847 ;; go to a different version
844 (setq version (read-string "Branch or version to move to: ")) 848 (setq version
845 (vc-checkout file (eq (vc-checkout-model file) 'implicit) version)) 849 (read-string "Branch, version, or backend to move to: "))
850 (let ((vsym (intern (upcase version))))
851 (if (member vsym vc-handled-backends)
852 (vc-transfer-file file vsym)
853 (vc-checkout file (eq (vc-checkout-model file) 'implicit)
854 version))))
846 ((not (eq (vc-checkout-model file) 'implicit)) 855 ((not (eq (vc-checkout-model file) 'implicit))
847 ;; check the file out 856 ;; check the file out
848 (vc-checkout file t)) 857 (vc-checkout file t))
@@ -876,8 +885,13 @@ If VERBOSE is non-nil, query the user rather than using default parameters."
876 (if (yes-or-no-p "Revert to master version? ") 885 (if (yes-or-no-p "Revert to master version? ")
877 (vc-revert-buffer))) 886 (vc-revert-buffer)))
878 (t ;; normal action 887 (t ;; normal action
879 (if verbose (setq version (read-string "New version: "))) 888 (if (not verbose)
880 (vc-checkin file version comment)))) 889 (vc-checkin file nil comment)
890 (setq version (read-string "New version or backend: "))
891 (let ((vsym (intern (upcase version))))
892 (if (member vsym vc-handled-backends)
893 (vc-transfer-file file vsym)
894 (vc-checkin file version comment)))))))
881 895
882 ;; locked by somebody else 896 ;; locked by somebody else
883 ((stringp state) 897 ((stringp state)
@@ -1044,8 +1058,8 @@ first backend that could register the file is used."
1044 1058
1045 (vc-start-entry buffer-file-name 1059 (vc-start-entry buffer-file-name
1046 (if set-version 1060 (if set-version
1047 (read-string "Initial version level for %s: " 1061 (read-string (format "Initial version level for %s: "
1048 (buffer-name)) 1062 (buffer-name)))
1049 ;; TODO: Use backend-specific init version. 1063 ;; TODO: Use backend-specific init version.
1050 vc-default-init-version) 1064 vc-default-init-version)
1051 (or comment (not vc-initial-comment)) 1065 (or comment (not vc-initial-comment))
@@ -1093,6 +1107,15 @@ The default is to return nil always."
1093The default implementation returns t for all files." 1107The default implementation returns t for all files."
1094 t) 1108 t)
1095 1109
1110(defun vc-unregister (file backend)
1111 "Unregister FILE from version control system BACKEND."
1112 (vc-call-backend backend 'unregister file)
1113 (vc-file-clearprops file))
1114
1115(defun vc-default-unregister (backend file)
1116 "Default implementation of vc-unregister, signals an error."
1117 (error "Unregistering files is not supported for %s" backend))
1118
1096(defun vc-resynch-window (file &optional keep noquery) 1119(defun vc-resynch-window (file &optional keep noquery)
1097 "If FILE is in the current buffer, either revert or unvisit it. 1120 "If FILE is in the current buffer, either revert or unvisit it.
1098The choice between revert (to see expanded keywords) and unvisit depends on 1121The choice between revert (to see expanded keywords) and unvisit depends on
@@ -1488,7 +1511,9 @@ files in or below it."
1488 ;; Gnus-5.8.5 sets up an autoload for diff-mode, even if it's 1511 ;; Gnus-5.8.5 sets up an autoload for diff-mode, even if it's
1489 ;; not available. Work around that. 1512 ;; not available. Work around that.
1490 (if (require 'diff-mode nil t) (diff-mode)) 1513 (if (require 'diff-mode nil t) (diff-mode))
1491 (vc-exec-after '(progn (goto-char (point-min)) 1514 (vc-exec-after '(progn (if (eq (buffer-size) 0)
1515 (insert "No differences found.\n"))
1516 (goto-char (point-min))
1492 (shrink-window-if-larger-than-buffer))) 1517 (shrink-window-if-larger-than-buffer)))
1493 t)) 1518 t))
1494 1519
@@ -2155,6 +2180,79 @@ A prefix argument NOREVERT means do not revert the buffer afterwards."
2155 (vc-resynch-buffer file t t))) 2180 (vc-resynch-buffer file t t)))
2156 (message "Version %s has been removed from the master" target)))) 2181 (message "Version %s has been removed from the master" target))))
2157 2182
2183;;;autoload
2184(defun vc-switch-backend (file backend)
2185 "Make BACKEND the current version control system for FILE.
2186FILE must already be registered in BACKEND. The change is not
2187permanent, only for the current session. This function only changes
2188VC's perspective on FILE, it does not register or unregister it."
2189 (interactive
2190 (list
2191 buffer-file-name
2192 (intern (upcase (read-string "Switch to backend: ")))))
2193 (vc-file-clearprops file)
2194 (vc-file-setprop file 'vc-backend backend)
2195 (vc-resynch-buffer file t t))
2196
2197(defun vc-index-of (backend)
2198 "Return the index of BACKEND in vc-handled-backends."
2199 (- (length vc-handled-backends)
2200 (length (memq backend vc-handled-backends))))
2201
2202;;;autoload
2203(defun vc-transfer-file (file new-backend)
2204 "Transfer FILE to another version control system NEW-BACKEND.
2205If NEW-BACKEND has a higher precedence than FILE's current backend
2206\(i.e. it comes earlier in vc-handled-backends), then register FILE in
2207NEW-BACKEND, using the version number from the current backend as the
2208base level. If NEW-BACKEND has a lower precedence than the current
2209backend, then commit all changes that were made under the current
2210backend to NEW-BACKEND, and unregister FILE from the current backend.
2211\(If FILE is not yet registered under NEW-BACKEND, register it.)"
2212 (let ((old-backend (vc-backend file)))
2213 (if (eq old-backend new-backend)
2214 (error "%s is the current backend of %s"
2215 new-backend file)
2216 (with-vc-properties
2217 file
2218 (vc-call-backend new-backend 'receive-file file
2219 (< (vc-index-of old-backend)
2220 (vc-index-of new-backend)))
2221 `((vc-backend ,new-backend))))
2222 (vc-resynch-buffer file t t)))
2223
2224(defun vc-default-receive-file (backend file move)
2225 "Let BACKEND receive FILE from another version control system.
2226If MOVE is non-nil, then FILE is unregistered from the old
2227backend and its comment history is used as the initial contents
2228of the log entry buffer."
2229 (let ((old-backend (vc-backend file))
2230 (rev (vc-workfile-version file))
2231 (state (vc-state file))
2232 (comment (and move
2233 (vc-find-backend-function old-backend 'comment-history)
2234 (vc-call 'comment-history file))))
2235 (if move (vc-unregister file old-backend))
2236 (vc-file-clearprops file)
2237 (if (not (vc-call-backend backend 'registered file))
2238 (with-vc-properties
2239 file
2240 ;; TODO: If the file was 'edited under the old backend,
2241 ;; this should actually register the version
2242 ;; it was based on.
2243 (vc-call-backend backend 'register file rev "")
2244 `((vc-backend ,backend)))
2245 (vc-file-setprop file 'vc-backend backend)
2246 (vc-file-setprop file 'vc-state 'edited)
2247 (set-file-modes file
2248 (logior (file-modes file) 128)))
2249 (when (or move (eq state 'edited))
2250 (vc-file-setprop file 'vc-state 'edited)
2251 ;; TODO: The comment history should actually become the
2252 ;; initial contents of the log entry buffer.
2253 (and comment (ring-insert vc-comment-ring comment))
2254 (vc-checkin file))))
2255
2158(defun vc-rename-master (oldmaster newfile templates) 2256(defun vc-rename-master (oldmaster newfile templates)
2159 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES." 2257 "Rename OLDMASTER to be the master file for NEWFILE based on TEMPLATES."
2160 (let* ((dir (file-name-directory (expand-file-name oldmaster))) 2258 (let* ((dir (file-name-directory (expand-file-name oldmaster)))