Mercurial > emacs
annotate lisp/vc-mcvs.el @ 51810:f48bdff09ea1
(Font Lock): Fix typo
author | Luc Teirlinck <teirllm@auburn.edu> |
---|---|
date | Tue, 08 Jul 2003 00:33:59 +0000 |
parents | 575459cc44fb |
children | 695cf19ef79e |
rev | line source |
---|---|
50646 | 1 ;;; vc-mcvs.el --- VC backend for the Meta-CVS version-control system |
2 | |
3 ;; Copyright (C) 1995,98,99,2000,01,02,2003 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: FSF (see vc.el for full credits) | |
6 ;; Maintainer: Stefan Monnier <monnier@gnu.org> | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
50779
02455099d549
Add a link to Meta-CVS home page.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50667
diff
changeset
|
27 ;; The home page of the Meta-CVS version control system is at |
02455099d549
Add a link to Meta-CVS home page.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50667
diff
changeset
|
28 ;; |
02455099d549
Add a link to Meta-CVS home page.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50667
diff
changeset
|
29 ;; http://users.footprints.net/~kaz/mcvs.html |
02455099d549
Add a link to Meta-CVS home page.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50667
diff
changeset
|
30 ;; |
50646 | 31 ;; This is derived from vc-cvs.el as follows: |
32 ;; - cp vc-cvs.el vc-mcvs.el | |
33 ;; - Replace CVS/ with MCVS/CVS/ | |
34 ;; - Replace 'CVS with 'MCVS | |
35 ;; - Replace -cvs- with -mcvs- | |
36 ;; - Replace most of the rest of CVS to Meta-CVS | |
37 ;; | |
38 ;; Then of course started the hacking. Only a small part of the code | |
39 ;; has been touched and not much more than that was tested, so if | |
40 ;; you bump into a bug, don't be surprised: just report it to me. | |
41 ;; | |
42 ;; What has been partly tested: | |
43 ;; - C-x v v to start editing a file that was checked out with CVSREAD on. | |
44 ;; - C-x v v to commit a file | |
45 ;; - C-x v = | |
46 ;; - C-x v l | |
47 ;; - C-x v i | |
48 ;; - C-x v g | |
50808
5a0d0a9219f3
(vc-mcvs-mode-line-string): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50779
diff
changeset
|
49 ;; - M-x vc-rename-file RET |
50646 | 50 |
51 ;;; Bugs: | |
52 | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
53 ;; - Retrieving snapshots doesn't filter `cvs update' output and thus |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
54 ;; parses bogus filenames. Don't know if it harms. |
50646 | 55 |
56 ;;; Code: | |
57 | |
58 (eval-when-compile (require 'vc)) | |
59 (require 'vc-cvs) | |
60 | |
61 ;;; | |
62 ;;; Customization options | |
63 ;;; | |
64 | |
65 (defcustom vc-mcvs-global-switches nil | |
66 "*Global switches to pass to any Meta-CVS command." | |
67 :type '(choice (const :tag "None" nil) | |
68 (string :tag "Argument String") | |
69 (repeat :tag "Argument List" | |
70 :value ("") | |
71 string)) | |
72 :version "21.4" | |
73 :group 'vc) | |
74 | |
75 (defcustom vc-mcvs-register-switches nil | |
76 "*Extra switches for registering a file into Meta-CVS. | |
77 A string or list of strings passed to the checkin program by | |
78 \\[vc-register]." | |
79 :type '(choice (const :tag "None" nil) | |
80 (string :tag "Argument String") | |
81 (repeat :tag "Argument List" | |
82 :value ("") | |
83 string)) | |
84 :version "21.4" | |
85 :group 'vc) | |
86 | |
87 (defcustom vc-mcvs-diff-switches nil | |
88 "*A string or list of strings specifying extra switches for cvs diff under VC." | |
89 :type '(choice (const :tag "None" nil) | |
90 (string :tag "Argument String") | |
91 (repeat :tag "Argument List" | |
92 :value ("") | |
93 string)) | |
94 :version "21.4" | |
95 :group 'vc) | |
96 | |
97 (defcustom vc-mcvs-header (or (cdr (assoc 'MCVS vc-header-alist)) | |
98 vc-cvs-header) | |
99 "*Header keywords to be inserted by `vc-insert-headers'." | |
100 :version "21.4" | |
101 :type '(repeat string) | |
102 :group 'vc) | |
103 | |
104 (defcustom vc-mcvs-use-edit vc-cvs-use-edit | |
105 "*Non-nil means to use `cvs edit' to \"check out\" a file. | |
106 This is only meaningful if you don't use the implicit checkout model | |
107 \(i.e. if you have $CVSREAD set)." | |
108 :type 'boolean | |
109 :version "21.4" | |
110 :group 'vc) | |
111 | |
112 ;;; | |
113 ;;; State-querying functions | |
114 ;;; | |
115 | |
116 ;;;###autoload (defun vc-mcvs-registered (file) | |
117 ;;;###autoload (let ((dir file)) | |
118 ;;;###autoload (while (and (stringp dir) | |
50963
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
119 ;;;###autoload (not (equal |
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
120 ;;;###autoload dir (setq dir (file-name-directory dir)))) |
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
121 ;;;###autoload dir) |
50646 | 122 ;;;###autoload (setq dir (if (file-directory-p |
50963
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
123 ;;;###autoload (expand-file-name "MCVS/CVS" dir)) |
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
124 ;;;###autoload t (directory-file-name dir)))) |
50646 | 125 ;;;###autoload (if (eq dir t) |
50963
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
126 ;;;###autoload (progn |
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
127 ;;;###autoload (load "vc-mcvs") |
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
128 ;;;###autoload (vc-mcvs-registered file))))) |
50646 | 129 |
130 (defun vc-mcvs-root (file) | |
131 "Return the root directory of a Meta-CVS project, if any." | |
50667
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
132 (or (vc-file-getprop file 'mcvs-root) |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
133 (vc-file-setprop |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
134 file 'mcvs-root |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
135 (let ((root nil)) |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
136 (while (not (or root |
50963
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
137 (equal file (setq file (file-name-directory file))) |
575459cc44fb
(vc-mcvs-registered, vc-mcvs-root): Check if file-name-directory returns nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50952
diff
changeset
|
138 (null file))) |
50667
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
139 (if (file-directory-p (expand-file-name "MCVS/CVS" file)) |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
140 (setq root file) |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
141 (setq file (directory-file-name file)))) |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
142 root)))) |
50646 | 143 |
144 (defun vc-mcvs-read (file) | |
50899
6b9cefee3eee
(vc-mcvs-read): Don't require `file' to exist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50808
diff
changeset
|
145 (if (file-readable-p file) |
6b9cefee3eee
(vc-mcvs-read): Don't require `file' to exist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50808
diff
changeset
|
146 (with-temp-buffer |
6b9cefee3eee
(vc-mcvs-read): Don't require `file' to exist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50808
diff
changeset
|
147 (insert-file-contents file) |
6b9cefee3eee
(vc-mcvs-read): Don't require `file' to exist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50808
diff
changeset
|
148 (goto-char (point-min)) |
6b9cefee3eee
(vc-mcvs-read): Don't require `file' to exist.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50808
diff
changeset
|
149 (read (current-buffer))))) |
50646 | 150 |
151 (defun vc-mcvs-map-file (dir file) | |
152 (let ((map (vc-mcvs-read (expand-file-name "MCVS/MAP" dir))) | |
153 inode) | |
154 (dolist (x map inode) | |
155 (if (equal (nth 2 x) file) (setq inode (nth 1 x)))))) | |
156 | |
157 (defun vc-mcvs-registered (file) | |
158 (let (root inode cvsfile) | |
159 (when (and (setq root (vc-mcvs-root file)) | |
160 (setq inode (vc-mcvs-map-file | |
50667
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
161 root (file-relative-name file root)))) |
50646 | 162 (vc-file-setprop file 'mcvs-inode inode) |
163 ;; Avoid calling `mcvs diff' in vc-workfile-unchanged-p. | |
164 (vc-file-setprop file 'vc-checkout-time | |
165 (if (vc-cvs-registered | |
166 (setq cvsfile (expand-file-name inode root))) | |
167 (vc-file-getprop cvsfile 'vc-checkout-time) | |
168 ;; The file might not be registered yet because | |
169 ;; of lazy-adding. | |
170 0)) | |
171 t))) | |
172 | |
173 (defmacro vc-mcvs-cvs (op file &rest args) | |
174 (declare (debug t)) | |
175 `(,(intern (concat "vc-cvs-" (symbol-name op))) | |
176 (expand-file-name (vc-file-getprop ,file 'mcvs-inode) | |
177 (vc-file-getprop ,file 'mcvs-root)) | |
178 ,@args)) | |
179 | |
180 (defun vc-mcvs-state (file) | |
181 ;; This would assume the Meta-CVS sandbox is synchronized. | |
182 ;; (vc-mcvs-cvs state file)) | |
183 "Meta-CVS-specific version of `vc-state'." | |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
184 (if (vc-stay-local-p file) |
50646 | 185 (let ((state (vc-file-getprop file 'vc-state))) |
186 ;; If we should stay local, use the heuristic but only if | |
187 ;; we don't have a more precise state already available. | |
188 (if (memq state '(up-to-date edited)) | |
189 (vc-mcvs-state-heuristic file) | |
190 state)) | |
191 (with-temp-buffer | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
192 (setq default-directory (vc-mcvs-root file)) |
50646 | 193 (vc-mcvs-command t 0 file "status") |
194 (vc-cvs-parse-status t)))) | |
195 | |
196 | |
197 (defalias 'vc-mcvs-state-heuristic 'vc-cvs-state-heuristic) | |
198 | |
199 (defun vc-mcvs-dir-state (dir) | |
200 "Find the Meta-CVS state of all files in DIR." | |
201 ;; if DIR is not under Meta-CVS control, don't do anything. | |
202 (when (file-readable-p (expand-file-name "MCVS/CVS/Entries" dir)) | |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
203 (if (vc-stay-local-p dir) |
50646 | 204 (vc-mcvs-dir-state-heuristic dir) |
205 (let ((default-directory dir)) | |
206 ;; Don't specify DIR in this command, the default-directory is | |
207 ;; enough. Otherwise it might fail with remote repositories. | |
208 (with-temp-buffer | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
209 (setq default-directory (vc-mcvs-root dir)) |
50646 | 210 (vc-mcvs-command t 0 nil "status" "-l") |
211 (goto-char (point-min)) | |
212 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t) | |
213 (narrow-to-region (match-beginning 0) (match-end 0)) | |
214 (vc-cvs-parse-status) | |
215 (goto-char (point-max)) | |
216 (widen))))))) | |
217 | |
218 (defun vc-mcvs-workfile-version (file) (vc-mcvs-cvs workfile-version file)) | |
219 | |
220 (defalias 'vc-mcvs-checkout-model 'vc-cvs-checkout-model) | |
221 | |
50808
5a0d0a9219f3
(vc-mcvs-mode-line-string): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50779
diff
changeset
|
222 (defun vc-mcvs-mode-line-string (file) |
5a0d0a9219f3
(vc-mcvs-mode-line-string): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50779
diff
changeset
|
223 (let ((s (vc-mcvs-cvs mode-line-string file))) |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
224 (when s |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
225 (if (and (not (memq (vc-state file) '(up-to-date needs-patch))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
226 (string-match "\\`CVS-" s)) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
227 ;; The CVS file is not in sync, so we need to adjust the state. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
228 (concat "MCVS:" (substring s 4)) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
229 (concat "M" s))))) |
50646 | 230 |
231 ;;; | |
232 ;;; State-changing functions | |
233 ;;; | |
234 | |
235 (defun vc-mcvs-register (file &optional rev comment) | |
236 "Register FILE into the Meta-CVS version-control system. | |
237 COMMENT can be used to provide an initial description of FILE. | |
238 | |
239 `vc-register-switches' and `vc-mcvs-register-switches' are passed to | |
240 the Meta-CVS command (in that order)." | |
241 (let* ((filename (file-name-nondirectory file)) | |
242 (extpos (string-match "\\." filename)) | |
243 (ext (if extpos (substring filename (1+ extpos)))) | |
244 (root (vc-mcvs-root file)) | |
245 (types-file (expand-file-name "MCVS/TYPES" root)) | |
246 (map-file (expand-file-name "MCVS/MAP" root)) | |
247 (types (vc-mcvs-read types-file))) | |
248 ;; Make sure meta files like MCVS/MAP are not read-only (happens with | |
249 ;; CVSREAD) since Meta-CVS doesn't pay attention to it at all and goes | |
250 ;; belly-up. | |
251 (unless (file-writable-p map-file) | |
252 (vc-checkout map-file t)) | |
50667
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
253 (unless (or (file-writable-p types-file) (not (file-exists-p types-file))) |
50646 | 254 (vc-checkout types-file t)) |
255 ;; Make sure the `mcvs add' will not fire up the CVSEDITOR | |
256 ;; to add a rule for the given file's extension. | |
257 (when (and ext (not (assoc ext types))) | |
258 (let ((type (completing-read "Type to use [default]: " | |
259 '("default" "name-only" "keep-old" | |
260 "binary" "value-only") | |
261 nil t nil nil "default"))) | |
262 (push (list ext (make-symbol (upcase (concat ":" type)))) types) | |
263 (setq types (sort types (lambda (x y) (string< (car x) (car y))))) | |
264 (with-current-buffer (find-file-noselect types-file) | |
265 (erase-buffer) | |
266 (pp types (current-buffer)) | |
267 (save-buffer) | |
268 (unless (get-buffer-window (current-buffer) t) | |
269 (kill-buffer (current-buffer))))))) | |
270 ;; Now do the ADD. | |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
271 (prog1 (apply 'vc-mcvs-command nil 0 file |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
272 "add" |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
273 (and comment (string-match "[^\t\n ]" comment) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
274 (concat "-m" comment)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
275 (vc-switches 'MCVS 'register)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
276 ;; I'm not sure exactly why, but if we don't setup the inode and root |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
277 ;; prop of the file, things break later on in vc-mode-line that |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
278 ;; ends up calling vc-mcvs-workfile-version. |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
279 ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
280 ;; doesn't try to call `mcvs diff' on the file. |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
281 (vc-mcvs-registered file))) |
50646 | 282 |
283 (defalias 'vc-mcvs-responsible-p 'vc-mcvs-root | |
284 "Return non-nil if CVS thinks it is responsible for FILE.") | |
285 | |
286 (defalias 'vc-cvs-could-register 'vc-cvs-responsible-p | |
287 "Return non-nil if FILE could be registered in Meta-CVS. | |
288 This is only possible if Meta-CVS is responsible for FILE's directory.") | |
289 | |
290 (defun vc-mcvs-checkin (file rev comment) | |
291 "Meta-CVS-specific version of `vc-backend-checkin'." | |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
292 (unless (or (not rev) (vc-mcvs-valid-version-number-p rev)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
293 (if (not (vc-mcvs-valid-symbolic-tag-name-p rev)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
294 (error "%s is not a valid symbolic tag name" rev) |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
295 ;; If the input revision is a valid symbolic tag name, we create it |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
296 ;; as a branch, commit and switch to it. |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
297 ;; This file-specific form of branching is deprecated. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
298 ;; We can't use `mcvs branch' and `mcvs switch' because they cannot |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
299 ;; be applied just to this one file. |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
300 (apply 'vc-mcvs-command nil 0 file "tag" "-b" (list rev)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
301 (apply 'vc-mcvs-command nil 0 file "update" "-r" (list rev)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
302 (vc-file-setprop file 'vc-mcvs-sticky-tag rev) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
303 (setq rev nil))) |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
304 ;; This commit might cvs-commit several files (e.g. MAP and TYPES) |
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
305 ;; so using numbered revs here is dangerous and somewhat meaningless. |
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
306 (when rev (error "Cannot commit to a specific revision number")) |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
307 (let ((status (apply 'vc-mcvs-command nil 1 file |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
308 "ci" "-m" comment |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
309 (vc-switches 'MCVS 'checkin)))) |
50646 | 310 (set-buffer "*vc*") |
311 (goto-char (point-min)) | |
312 (when (not (zerop status)) | |
313 ;; Check checkin problem. | |
314 (cond | |
315 ((re-search-forward "Up-to-date check failed" nil t) | |
316 (vc-file-setprop file 'vc-state 'needs-merge) | |
317 (error (substitute-command-keys | |
318 (concat "Up-to-date check failed: " | |
319 "type \\[vc-next-action] to merge in changes")))) | |
320 (t | |
321 (pop-to-buffer (current-buffer)) | |
322 (goto-char (point-min)) | |
323 (shrink-window-if-larger-than-buffer) | |
324 (error "Check-in failed")))) | |
325 ;; Update file properties | |
326 (vc-file-setprop | |
327 file 'vc-workfile-version | |
328 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2)) | |
329 ;; Forget the checkout model of the file, because we might have | |
330 ;; guessed wrong when we found the file. After commit, we can | |
331 ;; tell it from the permissions of the file (see | |
332 ;; vc-mcvs-checkout-model). | |
333 (vc-file-setprop file 'vc-checkout-model nil) | |
334 | |
335 ;; if this was an explicit check-in (does not include creation of | |
336 ;; a branch), remove the sticky tag. | |
337 (if (and rev (not (vc-mcvs-valid-symbolic-tag-name-p rev))) | |
338 (vc-mcvs-command nil 0 file "update" "-A")))) | |
339 | |
340 (defun vc-mcvs-find-version (file rev buffer) | |
341 (apply 'vc-mcvs-command | |
342 buffer 0 file | |
343 "-Q" ; suppress diagnostic output | |
344 "update" | |
345 (and rev (not (string= rev "")) | |
346 (concat "-r" rev)) | |
347 "-p" | |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
348 (vc-switches 'MCVS 'checkout))) |
50646 | 349 |
350 (defun vc-mcvs-checkout (file &optional editable rev) | |
351 (message "Checking out %s..." file) | |
352 (with-current-buffer (or (get-file-buffer file) (current-buffer)) | |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
353 (vc-call update file editable rev (vc-switches 'MCVS 'checkout))) |
50646 | 354 (vc-mode-line file) |
355 (message "Checking out %s...done" file)) | |
356 | |
357 (defun vc-mcvs-update (file editable rev switches) | |
358 (if (and (file-exists-p file) (not rev)) | |
359 ;; If no revision was specified, just make the file writable | |
360 ;; if necessary (using `cvs-edit' if requested). | |
361 (and editable (not (eq (vc-mcvs-checkout-model file) 'implicit)) | |
362 (if vc-mcvs-use-edit | |
363 (vc-mcvs-command nil 0 file "edit") | |
364 (set-file-modes file (logior (file-modes file) 128)) | |
365 (if (equal file buffer-file-name) (toggle-read-only -1)))) | |
366 ;; Check out a particular version (or recreate the file). | |
367 (vc-file-setprop file 'vc-workfile-version nil) | |
368 (apply 'vc-mcvs-command nil 0 file | |
369 (if editable "-w") | |
370 "update" | |
371 ;; default for verbose checkout: clear the sticky tag so | |
372 ;; that the actual update will get the head of the trunk | |
373 (if (or (not rev) (string= rev "")) | |
374 "-A" | |
375 (concat "-r" rev)) | |
376 switches))) | |
377 | |
50808
5a0d0a9219f3
(vc-mcvs-mode-line-string): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50779
diff
changeset
|
378 (defun vc-mcvs-rename-file (old new) |
5a0d0a9219f3
(vc-mcvs-mode-line-string): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50779
diff
changeset
|
379 (vc-mcvs-command nil 0 new "move" (file-relative-name old))) |
5a0d0a9219f3
(vc-mcvs-mode-line-string): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50779
diff
changeset
|
380 |
50646 | 381 (defun vc-mcvs-revert (file &optional contents-done) |
382 "Revert FILE to the version it was based on." | |
383 (vc-default-revert file contents-done) | |
384 (unless (eq (vc-checkout-model file) 'implicit) | |
385 (if vc-mcvs-use-edit | |
386 (vc-mcvs-command nil 0 file "unedit") | |
387 ;; Make the file read-only by switching off all w-bits | |
388 (set-file-modes file (logand (file-modes file) 3950))))) | |
389 | |
390 (defun vc-mcvs-merge (file first-version &optional second-version) | |
391 "Merge changes into current working copy of FILE. | |
392 The changes are between FIRST-VERSION and SECOND-VERSION." | |
393 (vc-mcvs-command nil 0 file | |
394 "update" "-kk" | |
395 (concat "-j" first-version) | |
396 (concat "-j" second-version)) | |
397 (vc-file-setprop file 'vc-state 'edited) | |
398 (with-current-buffer (get-buffer "*vc*") | |
399 (goto-char (point-min)) | |
400 (if (re-search-forward "conflicts during merge" nil t) | |
401 1 ; signal error | |
402 0))) ; signal success | |
403 | |
404 (defun vc-mcvs-merge-news (file) | |
405 "Merge in any new changes made to FILE." | |
406 (message "Merging changes into %s..." file) | |
407 ;; (vc-file-setprop file 'vc-workfile-version nil) | |
408 (vc-file-setprop file 'vc-checkout-time 0) | |
409 (vc-mcvs-command nil 0 file "update") | |
410 ;; Analyze the merge result reported by Meta-CVS, and set | |
411 ;; file properties accordingly. | |
412 (with-current-buffer (get-buffer "*vc*") | |
413 (goto-char (point-min)) | |
414 ;; get new workfile version | |
415 (if (re-search-forward | |
416 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t) | |
417 (vc-file-setprop file 'vc-workfile-version (match-string 1)) | |
418 (vc-file-setprop file 'vc-workfile-version nil)) | |
419 ;; get file status | |
420 (prog1 | |
421 (if (eq (buffer-size) 0) | |
422 0 ;; there were no news; indicate success | |
423 (if (re-search-forward | |
424 (concat "^\\([CMUP] \\)?" | |
425 ".*" | |
426 "\\( already contains the differences between \\)?") | |
427 nil t) | |
428 (cond | |
429 ;; Merge successful, we are in sync with repository now | |
430 ((or (match-string 2) | |
431 (string= (match-string 1) "U ") | |
432 (string= (match-string 1) "P ")) | |
433 (vc-file-setprop file 'vc-state 'up-to-date) | |
434 (vc-file-setprop file 'vc-checkout-time | |
435 (nth 5 (file-attributes file))) | |
436 0);; indicate success to the caller | |
437 ;; Merge successful, but our own changes are still in the file | |
438 ((string= (match-string 1) "M ") | |
439 (vc-file-setprop file 'vc-state 'edited) | |
440 0);; indicate success to the caller | |
441 ;; Conflicts detected! | |
442 (t | |
443 (vc-file-setprop file 'vc-state 'edited) | |
444 1);; signal the error to the caller | |
445 ) | |
446 (pop-to-buffer "*vc*") | |
447 (error "Couldn't analyze mcvs update result"))) | |
448 (message "Merging changes into %s...done" file)))) | |
449 | |
450 ;;; | |
451 ;;; History functions | |
452 ;;; | |
453 | |
454 (defun vc-mcvs-print-log (file) | |
455 "Get change log associated with FILE." | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
456 (let ((default-directory (vc-mcvs-root file))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
457 ;; Run the command from the root dir so that `mcvs filt' returns |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
458 ;; valid relative names. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
459 (vc-mcvs-command |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
460 nil |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
461 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
462 file "log"))) |
50646 | 463 |
464 (defun vc-mcvs-diff (file &optional oldvers newvers) | |
465 "Get a difference report using Meta-CVS between two versions of FILE." | |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
466 (if (string= (vc-workfile-version file) "0") |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
467 ;; This file is added but not yet committed; there is no master file. |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
468 (if (or oldvers newvers) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
469 (error "No revisions of %s exist" file) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
470 ;; We regard this as "changed". |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
471 ;; Diff it against /dev/null. |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
472 ;; Note: this is NOT a "mcvs diff". |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
473 (apply 'vc-do-command "*vc-diff*" |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
474 1 "diff" file |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
475 (append (vc-switches nil 'diff) '("/dev/null"))) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
476 ;; Even if it's empty, it's locally modified. |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
477 1) |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
478 (let* ((async (and (vc-stay-local-p file) (fboundp 'start-process))) |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
479 ;; Run the command from the root dir so that `mcvs filt' returns |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
480 ;; valid relative names. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
481 (default-directory (vc-mcvs-root file)) |
50901
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
482 (status |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
483 (apply 'vc-mcvs-command "*vc-diff*" |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
484 (if async 'async 1) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
485 file "diff" |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
486 (and oldvers (concat "-r" oldvers)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
487 (and newvers (concat "-r" newvers)) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
488 (vc-switches 'MCVS 'diff)))) |
d3bb1d77a4b1
(vc-mcvs-register, vc-mcvs-checkin, vc-mcvs-find-version)
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50899
diff
changeset
|
489 (if async 1 status)))) ; async diff, pessimistic assumption. |
50646 | 490 |
491 (defun vc-mcvs-diff-tree (dir &optional rev1 rev2) | |
492 "Diff all files at and below DIR." | |
493 (with-current-buffer "*vc-diff*" | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
494 ;; Run the command from the root dir so that `mcvs filt' returns |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
495 ;; valid relative names. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
496 (setq default-directory (vc-mcvs-root dir)) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
497 ;; cvs diff: use a single call for the entire tree |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
498 (let ((coding-system-for-read (or coding-system-for-read 'undecided))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
499 (apply 'vc-mcvs-command "*vc-diff*" 1 dir "diff" |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
500 (and rev1 (concat "-r" rev1)) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
501 (and rev2 (concat "-r" rev2)) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
502 (vc-switches 'MCVS 'diff))))) |
50646 | 503 |
504 (defun vc-mcvs-annotate-command (file buffer &optional version) | |
505 "Execute \"mcvs annotate\" on FILE, inserting the contents in BUFFER. | |
506 Optional arg VERSION is a version to annotate from." | |
507 (vc-mcvs-command | |
508 buffer | |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
509 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) |
50646 | 510 file "annotate" (if version (concat "-r" version)))) |
511 | |
512 (defalias 'vc-mcvs-annotate-current-time 'vc-cvs-annotate-current-time) | |
513 (defalias 'vc-mcvs-annotate-time 'vc-cvs-annotate-time) | |
514 | |
515 ;;; | |
516 ;;; Snapshot system | |
517 ;;; | |
518 | |
519 (defun vc-mcvs-create-snapshot (dir name branchp) | |
520 "Assign to DIR's current version a given NAME. | |
521 If BRANCHP is non-nil, the name is created as a branch (and the current | |
522 workspace is immediately moved to that new branch)." | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
523 (if (not branchp) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
524 (vc-mcvs-command nil 0 dir "tag" "-c" name) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
525 (vc-mcvs-command nil 0 dir "branch" name) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
526 (vc-mcvs-command nil 0 dir "switch" name))) |
50646 | 527 |
528 (defun vc-mcvs-retrieve-snapshot (dir name update) | |
529 "Retrieve a snapshot at and below DIR. | |
530 NAME is the name of the snapshot; if it is empty, do a `cvs update'. | |
531 If UPDATE is non-nil, then update (resynch) any affected buffers." | |
532 (with-current-buffer (get-buffer-create "*vc*") | |
533 (let ((default-directory dir) | |
534 (sticky-tag)) | |
535 (erase-buffer) | |
536 (if (or (not name) (string= name "")) | |
537 (vc-mcvs-command t 0 nil "update") | |
538 (vc-mcvs-command t 0 nil "update" "-r" name) | |
539 (setq sticky-tag name)) | |
540 (when update | |
541 (goto-char (point-min)) | |
542 (while (not (eobp)) | |
543 (if (looking-at "\\([CMUP]\\) \\(.*\\)") | |
544 (let* ((file (expand-file-name (match-string 2) dir)) | |
545 (state (match-string 1)) | |
546 (buffer (find-buffer-visiting file))) | |
547 (when buffer | |
548 (cond | |
549 ((or (string= state "U") | |
550 (string= state "P")) | |
551 (vc-file-setprop file 'vc-state 'up-to-date) | |
552 (vc-file-setprop file 'vc-workfile-version nil) | |
553 (vc-file-setprop file 'vc-checkout-time | |
554 (nth 5 (file-attributes file)))) | |
555 ((or (string= state "M") | |
556 (string= state "C")) | |
557 (vc-file-setprop file 'vc-state 'edited) | |
558 (vc-file-setprop file 'vc-workfile-version nil) | |
559 (vc-file-setprop file 'vc-checkout-time 0))) | |
560 (vc-file-setprop file 'vc-mcvs-sticky-tag sticky-tag) | |
561 (vc-resynch-buffer file t t)))) | |
562 (forward-line 1)))))) | |
563 | |
564 | |
565 ;;; | |
566 ;;; Miscellaneous | |
567 ;;; | |
568 | |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
569 (defalias 'vc-mcvs-make-version-backups-p 'vc-stay-local-p |
50646 | 570 "Return non-nil if version backups should be made for FILE.") |
571 (defalias 'vc-mcvs-check-headers 'vc-cvs-check-headers) | |
572 | |
573 | |
574 ;;; | |
575 ;;; Internal functions | |
576 ;;; | |
577 | |
578 (defun vc-mcvs-command (buffer okstatus file &rest flags) | |
579 "A wrapper around `vc-do-command' for use in vc-mcvs.el. | |
580 The difference to vc-do-command is that this function always invokes `mcvs', | |
581 and that it passes `vc-mcvs-global-switches' to it before FLAGS." | |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
582 (let ((args (append '("--error-terminate") |
50667
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
583 (if (stringp vc-mcvs-global-switches) |
c475369e6995
(vc-mcvs-root): Cache the result.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50646
diff
changeset
|
584 (cons vc-mcvs-global-switches flags) |
50952
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
585 (append vc-mcvs-global-switches flags))))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
586 (if (not (member (car flags) '("diff" "log" "status"))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
587 ;; No need to filter: do it the easy way. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
588 (apply 'vc-do-command buffer okstatus "mcvs" file args) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
589 ;; We need to filter the output. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
590 ;; The output of the filter uses filenames relative to the root, |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
591 ;; so we need to change the default-directory. |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
592 (assert (equal default-directory (vc-mcvs-root file))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
593 (vc-do-command |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
594 buffer okstatus "sh" nil "-c" |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
595 (concat "mcvs " |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
596 (mapconcat |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
597 'shell-quote-argument |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
598 (append (remq nil args) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
599 (if file (list (file-relative-name file)))) |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
600 " ") |
1731748fbe8c
(vc-mcvs-command): Filter output of `status'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50928
diff
changeset
|
601 " | mcvs filt"))))) |
50646 | 602 |
50928
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
603 (defun vc-mcvs-repository-hostname (dirname) |
dc235df7e226
(vc-mcvs-stay-local): Remove unused var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
50924
diff
changeset
|
604 (vc-cvs-repository-hostname (vc-mcvs-root dirname))) |
50646 | 605 |
606 (defun vc-mcvs-dir-state-heuristic (dir) | |
607 "Find the Meta-CVS state of all files in DIR, using only local information." | |
608 (with-temp-buffer | |
609 (vc-cvs-get-entries dir) | |
610 (goto-char (point-min)) | |
611 (while (not (eobp)) | |
612 ;; Meta-MCVS-removed files are not taken under VC control. | |
613 (when (looking-at "/\\([^/]*\\)/[^/-]") | |
614 (let ((file (expand-file-name (match-string 1) dir))) | |
615 (unless (vc-file-getprop file 'vc-state) | |
616 (vc-cvs-parse-entry file t)))) | |
617 (forward-line 1)))) | |
618 | |
619 (defalias 'vc-mcvs-valid-symbolic-tag-name-p 'vc-cvs-valid-symbolic-tag-name-p) | |
620 (defalias 'vc-mcvs-valid-version-number-p 'vc-cvs-valid-version-number-p) | |
621 | |
622 (provide 'vc-mcvs) | |
623 ;;; vc-mcvs.el ends here |