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