]> code.delx.au - gnu-emacs/blob - lisp/vc-mcvs.el
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
[gnu-emacs] / lisp / vc-mcvs.el
1 ;;; vc-mcvs.el --- VC backend for the Meta-CVS version-control system
2
3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007 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., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Commentary:
26
27 ;; The home page of the Meta-CVS version control system is at
28 ;;
29 ;; http://users.footprints.net/~kaz/mcvs.html
30 ;;
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
49 ;; - M-x vc-rename-file RET
50
51 ;;; Bugs:
52
53 ;; - Retrieving snapshots doesn't filter `cvs update' output and thus
54 ;; parses bogus filenames. Don't know if it harms.
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 "22.1"
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 "22.1"
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 "22.1"
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 "22.1"
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 "22.1"
110 :group 'vc)
111
112 ;;; Properties of the backend
113
114 (defun vc-mcvs-revision-granularity ()
115 'file)
116
117 ;;;
118 ;;; State-querying functions
119 ;;;
120
121 ;;;###autoload (defun vc-mcvs-registered (file)
122 ;;;###autoload (if (vc-find-root file "MCVS/CVS")
123 ;;;###autoload (progn
124 ;;;###autoload (load "vc-mcvs")
125 ;;;###autoload (vc-mcvs-registered file))))
126
127 (defun vc-mcvs-root (file)
128 "Return the root directory of a Meta-CVS project, if any."
129 (or (vc-file-getprop file 'mcvs-root)
130 (vc-file-setprop file 'mcvs-root (vc-find-root file "MCVS/CVS"))))
131
132 (defun vc-mcvs-read (file)
133 (if (file-readable-p file)
134 (with-temp-buffer
135 (insert-file-contents file)
136 (goto-char (point-min))
137 (read (current-buffer)))))
138
139 (defun vc-mcvs-map-file (dir file)
140 (let ((map (vc-mcvs-read (expand-file-name "MCVS/MAP" dir)))
141 inode)
142 (dolist (x map inode)
143 (if (equal (nth 2 x) file) (setq inode (nth 1 x))))))
144
145 (defun vc-mcvs-registered (file)
146 (let (root inode cvsfile)
147 (when (and (setq root (vc-mcvs-root file))
148 (setq inode (vc-mcvs-map-file
149 root (file-relative-name file root))))
150 (vc-file-setprop file 'mcvs-inode inode)
151 ;; Avoid calling `mcvs diff' in vc-workfile-unchanged-p.
152 (vc-file-setprop file 'vc-checkout-time
153 (if (vc-cvs-registered
154 (setq cvsfile (expand-file-name inode root)))
155 (vc-file-getprop cvsfile 'vc-checkout-time)
156 ;; The file might not be registered yet because
157 ;; of lazy-adding.
158 0))
159 t)))
160
161 (defun vc-mcvs-state (file)
162 ;; This would assume the Meta-CVS sandbox is synchronized.
163 ;; (vc-mcvs-cvs state file))
164 "Meta-CVS-specific version of `vc-state'."
165 (if (vc-stay-local-p file)
166 (let ((state (vc-file-getprop file 'vc-state)))
167 ;; If we should stay local, use the heuristic but only if
168 ;; we don't have a more precise state already available.
169 (if (memq state '(up-to-date edited))
170 (vc-mcvs-state-heuristic file)
171 state))
172 (with-temp-buffer
173 (setq default-directory (vc-mcvs-root file))
174 (vc-mcvs-command t 0 file "status")
175 (vc-cvs-parse-status t))))
176
177
178 (defalias 'vc-mcvs-state-heuristic 'vc-cvs-state-heuristic)
179
180 (defun vc-mcvs-dir-state (dir)
181 "Find the Meta-CVS state of all files in DIR."
182 ;; if DIR is not under Meta-CVS control, don't do anything.
183 (when (file-readable-p (expand-file-name "MCVS/CVS/Entries" dir))
184 (if (vc-stay-local-p dir)
185 (vc-mcvs-dir-state-heuristic dir)
186 (let ((default-directory dir))
187 ;; Don't specify DIR in this command, the default-directory is
188 ;; enough. Otherwise it might fail with remote repositories.
189 (with-temp-buffer
190 (setq default-directory (vc-mcvs-root dir))
191 (vc-mcvs-command t 0 nil "status" "-l")
192 (goto-char (point-min))
193 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
194 (narrow-to-region (match-beginning 0) (match-end 0))
195 (vc-cvs-parse-status)
196 (goto-char (point-max))
197 (widen)))))))
198
199 (defun vc-mcvs-workfile-version (file)
200 (vc-cvs-workfile-version
201 (expand-file-name (vc-file-getprop file 'mcvs-inode)
202 (vc-file-getprop file 'mcvs-root))))
203
204 (defalias 'vc-mcvs-checkout-model 'vc-cvs-checkout-model)
205
206 ;;;
207 ;;; State-changing functions
208 ;;;
209
210 (defun vc-mcvs-create-repo ()
211 "Create a new Meta-CVS repository."
212 (error "Creation of Meta-CVS repositories is not supported."))
213
214 (defun vc-mcvs-register (files &optional rev comment)
215 "Register FILES into the Meta-CVS version-control system.
216 COMMENT can be used to provide an initial description of FILE.
217
218 `vc-register-switches' and `vc-mcvs-register-switches' are passed to
219 the Meta-CVS command (in that order)."
220 ;; FIXME: multiple-file case should be made to work
221 (if (> (length files) 1) (error "Registering filesets is not yet supported."))
222 (let* ((file (car files))
223 (filename (file-name-nondirectory file))
224 (extpos (string-match "\\." filename))
225 (ext (if extpos (substring filename (1+ extpos))))
226 (root (vc-mcvs-root file))
227 (types-file (expand-file-name "MCVS/TYPES" root))
228 (map-file (expand-file-name "MCVS/MAP" root))
229 (types (vc-mcvs-read types-file)))
230 ;; Make sure meta files like MCVS/MAP are not read-only (happens with
231 ;; CVSREAD) since Meta-CVS doesn't pay attention to it at all and goes
232 ;; belly-up.
233 (unless (file-writable-p map-file)
234 (vc-checkout map-file t))
235 (unless (or (file-writable-p types-file) (not (file-exists-p types-file)))
236 (vc-checkout types-file t))
237 ;; Make sure the `mcvs add' will not fire up the CVSEDITOR
238 ;; to add a rule for the given file's extension.
239 (when (and ext (not (assoc ext types)))
240 (let ((type (completing-read "Type to use (default): "
241 '("default" "name-only" "keep-old"
242 "binary" "value-only")
243 nil t nil nil "default")))
244 (push (list ext (make-symbol (upcase (concat ":" type)))) types)
245 (setq types (sort types (lambda (x y) (string< (car x) (car y)))))
246 (with-current-buffer (find-file-noselect types-file)
247 (erase-buffer)
248 (pp types (current-buffer))
249 (save-buffer)
250 (unless (get-buffer-window (current-buffer) t)
251 (kill-buffer (current-buffer)))))))
252 ;; Now do the ADD.
253 (prog1 (apply 'vc-mcvs-command nil 0 file
254 "add"
255 (and comment (string-match "[^\t\n ]" comment)
256 (concat "-m" comment))
257 (vc-switches 'MCVS 'register))
258 ;; I'm not sure exactly why, but if we don't setup the inode and root
259 ;; prop of the file, things break later on in vc-mode-line that
260 ;; ends up calling vc-mcvs-workfile-version.
261 ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p
262 ;; doesn't try to call `mcvs diff' on the file.
263 (vc-mcvs-registered file)))
264
265 (defalias 'vc-mcvs-responsible-p 'vc-mcvs-root
266 "Return non-nil if CVS thinks it is responsible for FILE.")
267
268 (defalias 'vc-cvs-could-register 'vc-cvs-responsible-p
269 "Return non-nil if FILE could be registered in Meta-CVS.
270 This is only possible if Meta-CVS is responsible for FILE's directory.")
271
272 (defun vc-mcvs-checkin (files rev comment)
273 "Meta-CVS-specific version of `vc-backend-checkin'."
274 (unless (or (not rev) (vc-mcvs-valid-version-number-p rev))
275 (if (not (vc-mcvs-valid-symbolic-tag-name-p rev))
276 (error "%s is not a valid symbolic tag name" rev)
277 ;; If the input revision is a valid symbolic tag name, we create it
278 ;; as a branch, commit and switch to it.
279 ;; This file-specific form of branching is deprecated.
280 ;; We can't use `mcvs branch' and `mcvs switch' because they cannot
281 ;; be applied just to this one file.
282 (apply 'vc-mcvs-command nil 0 files "tag" "-b" (list rev))
283 (apply 'vc-mcvs-command nil 0 files "update" "-r" (list rev))
284 (mapcar (lambda (file) (vc-file-setprop file 'vc-mcvs-sticky-tag rev))
285 files)
286 (setq rev nil)))
287 ;; This commit might cvs-commit several files (e.g. MAP and TYPES)
288 ;; so using numbered revs here is dangerous and somewhat meaningless.
289 (when rev (error "Cannot commit to a specific revision number"))
290 (let ((status (apply 'vc-mcvs-command nil 1 files
291 "ci" "-m" comment
292 (vc-switches 'MCVS 'checkin))))
293 (set-buffer "*vc*")
294 (goto-char (point-min))
295 (when (not (zerop status))
296 ;; Check checkin problem.
297 (cond
298 ((re-search-forward "Up-to-date check failed" nil t)
299 (mapcar (lambda (file) (vc-file-setprop file 'vc-state 'needs-merge))
300 files)
301 (error (substitute-command-keys
302 (concat "Up-to-date check failed: "
303 "type \\[vc-next-action] to merge in changes"))))
304 (t
305 (pop-to-buffer (current-buffer))
306 (goto-char (point-min))
307 (shrink-window-if-larger-than-buffer)
308 (error "Check-in failed"))))
309 ;; Single-file commit? Then update the version by parsing the buffer.
310 ;; Otherwise we can't necessarily tell what goes with what; clear
311 ;; its properties so they have to be refetched.
312 (if (= (length files) 1)
313 (vc-file-setprop
314 (car files) 'vc-workfile-version
315 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
316 (mapc (lambda (file) (vc-file-clearprops file)) files))
317 ;; Anyway, forget the checkout model of the file, because we might have
318 ;; guessed wrong when we found the file. After commit, we can
319 ;; tell it from the permissions of the file (see
320 ;; vc-mcvs-checkout-model).
321 (mapc (lambda (file) (vc-file-setprop file 'vc-checkout-model nil))
322 files)
323
324 ;; if this was an explicit check-in (does not include creation of
325 ;; a branch), remove the sticky tag.
326 (if (and rev (not (vc-mcvs-valid-symbolic-tag-name-p rev)))
327 (vc-mcvs-command nil 0 files "update" "-A"))))
328
329 (defun vc-mcvs-find-version (file rev buffer)
330 (apply 'vc-mcvs-command
331 buffer 0 file
332 "-Q" ; suppress diagnostic output
333 "update"
334 (and rev (not (string= rev ""))
335 (concat "-r" rev))
336 "-p"
337 (vc-switches 'MCVS 'checkout)))
338
339 (defun vc-mcvs-checkout (file &optional editable rev)
340 (message "Checking out %s..." file)
341 (with-current-buffer (or (get-file-buffer file) (current-buffer))
342 (vc-call update file editable rev (vc-switches 'MCVS 'checkout)))
343 (vc-mode-line file)
344 (message "Checking out %s...done" file))
345
346 (defun vc-mcvs-update (file editable rev switches)
347 (if (and (file-exists-p file) (not rev))
348 ;; If no revision was specified, just make the file writable
349 ;; if necessary (using `cvs-edit' if requested).
350 (and editable (not (eq (vc-mcvs-checkout-model file) 'implicit))
351 (if vc-mcvs-use-edit
352 (vc-mcvs-command nil 0 file "edit")
353 (set-file-modes file (logior (file-modes file) 128))
354 (if (equal file buffer-file-name) (toggle-read-only -1))))
355 ;; Check out a particular version (or recreate the file).
356 (vc-file-setprop file 'vc-workfile-version nil)
357 (apply 'vc-mcvs-command nil 0 file
358 (if editable "-w")
359 "update"
360 ;; default for verbose checkout: clear the sticky tag so
361 ;; that the actual update will get the head of the trunk
362 (if (or (not rev) (string= rev ""))
363 "-A"
364 (concat "-r" rev))
365 switches)))
366
367 (defun vc-mcvs-rename-file (old new)
368 (vc-mcvs-command nil 0 new "move" (file-relative-name old)))
369
370 (defun vc-mcvs-revert (file &optional contents-done)
371 "Revert FILE to the version it was based on."
372 (vc-default-revert 'MCVS file contents-done)
373 (unless (eq (vc-checkout-model file) 'implicit)
374 (if vc-mcvs-use-edit
375 (vc-mcvs-command nil 0 file "unedit")
376 ;; Make the file read-only by switching off all w-bits
377 (set-file-modes file (logand (file-modes file) 3950)))))
378
379 (defun vc-mcvs-merge (file first-version &optional second-version)
380 "Merge changes into current working copy of FILE.
381 The changes are between FIRST-VERSION and SECOND-VERSION."
382 (vc-mcvs-command nil 0 file
383 "update" "-kk"
384 (concat "-j" first-version)
385 (concat "-j" second-version))
386 (vc-file-setprop file 'vc-state 'edited)
387 (with-current-buffer (get-buffer "*vc*")
388 (goto-char (point-min))
389 (if (re-search-forward "conflicts during merge" nil t)
390 1 ; signal error
391 0))) ; signal success
392
393 (defun vc-mcvs-merge-news (file)
394 "Merge in any new changes made to FILE."
395 (message "Merging changes into %s..." file)
396 ;; (vc-file-setprop file 'vc-workfile-version nil)
397 (vc-file-setprop file 'vc-checkout-time 0)
398 (vc-mcvs-command nil 0 file "update")
399 ;; Analyze the merge result reported by Meta-CVS, and set
400 ;; file properties accordingly.
401 (with-current-buffer (get-buffer "*vc*")
402 (goto-char (point-min))
403 ;; get new workfile version
404 (if (re-search-forward
405 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t)
406 (vc-file-setprop file 'vc-workfile-version (match-string 1))
407 (vc-file-setprop file 'vc-workfile-version nil))
408 ;; get file status
409 (prog1
410 (if (eq (buffer-size) 0)
411 0 ;; there were no news; indicate success
412 (if (re-search-forward
413 (concat "^\\([CMUP] \\)?"
414 ".*"
415 "\\( already contains the differences between \\)?")
416 nil t)
417 (cond
418 ;; Merge successful, we are in sync with repository now
419 ((or (match-string 2)
420 (string= (match-string 1) "U ")
421 (string= (match-string 1) "P "))
422 (vc-file-setprop file 'vc-state 'up-to-date)
423 (vc-file-setprop file 'vc-checkout-time
424 (nth 5 (file-attributes file)))
425 0);; indicate success to the caller
426 ;; Merge successful, but our own changes are still in the file
427 ((string= (match-string 1) "M ")
428 (vc-file-setprop file 'vc-state 'edited)
429 0);; indicate success to the caller
430 ;; Conflicts detected!
431 (t
432 (vc-file-setprop file 'vc-state 'edited)
433 1);; signal the error to the caller
434 )
435 (pop-to-buffer "*vc*")
436 (error "Couldn't analyze mcvs update result")))
437 (message "Merging changes into %s...done" file))))
438
439 ;;;
440 ;;; History functions
441 ;;;
442
443 (defun vc-mcvs-print-log (files &optional buffer)
444 "Get change log associated with FILES."
445 (let ((default-directory (vc-mcvs-root (car files))))
446 ;; Run the command from the root dir so that `mcvs filt' returns
447 ;; valid relative names.
448 (vc-mcvs-command
449 buffer
450 (if (and (vc-stay-local-p files) (fboundp 'start-process)) 'async 0)
451 files "log")))
452
453 (defun vc-mcvs-diff (files &optional oldvers newvers buffer)
454 "Get a difference report using Meta-CVS between two versions of FILES."
455 (let* ((async (and (not vc-disable-async-diff)
456 (vc-stay-local-p files)
457 (fboundp 'start-process)))
458 ;; Run the command from the root dir so that `mcvs filt' returns
459 ;; valid relative names.
460 (default-directory (vc-mcvs-root (car files)))
461 (status
462 (apply 'vc-mcvs-command (or buffer "*vc-diff*")
463 (if async 'async 1)
464 files "diff"
465 (and oldvers (concat "-r" oldvers))
466 (and newvers (concat "-r" newvers))
467 (vc-switches 'MCVS 'diff))))
468 (if async 1 status))) ; async diff, pessimistic assumption.
469
470 (defun vc-mcvs-diff-tree (dir &optional rev1 rev2)
471 "Diff all files at and below DIR."
472 (with-current-buffer "*vc-diff*"
473 ;; Run the command from the root dir so that `mcvs filt' returns
474 ;; valid relative names.
475 (setq default-directory (vc-mcvs-root dir))
476 ;; cvs diff: use a single call for the entire tree
477 (let ((coding-system-for-read (or coding-system-for-read 'undecided)))
478 (apply 'vc-mcvs-command "*vc-diff*" 1 dir "diff"
479 (and rev1 (concat "-r" rev1))
480 (and rev2 (concat "-r" rev2))
481 (vc-switches 'MCVS 'diff)))))
482
483 (defun vc-mcvs-annotate-command (file buffer &optional version)
484 "Execute \"mcvs annotate\" on FILE, inserting the contents in BUFFER.
485 Optional arg VERSION is a version to annotate from."
486 (vc-mcvs-command
487 buffer
488 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
489 file "annotate" (if version (concat "-r" version)))
490 (with-current-buffer buffer
491 (goto-char (point-min))
492 (re-search-forward "^[0-9]")
493 (delete-region (point-min) (1- (point)))))
494
495 (defalias 'vc-mcvs-annotate-current-time 'vc-cvs-annotate-current-time)
496 (defalias 'vc-mcvs-annotate-time 'vc-cvs-annotate-time)
497
498 ;;;
499 ;;; Snapshot system
500 ;;;
501
502 (defun vc-mcvs-create-snapshot (dir name branchp)
503 "Assign to DIR's current version a given NAME.
504 If BRANCHP is non-nil, the name is created as a branch (and the current
505 workspace is immediately moved to that new branch)."
506 (if (not branchp)
507 (vc-mcvs-command nil 0 dir "tag" "-c" name)
508 (vc-mcvs-command nil 0 dir "branch" name)
509 (vc-mcvs-command nil 0 dir "switch" name)))
510
511 (defun vc-mcvs-retrieve-snapshot (dir name update)
512 "Retrieve a snapshot at and below DIR.
513 NAME is the name of the snapshot; if it is empty, do a `cvs update'.
514 If UPDATE is non-nil, then update (resynch) any affected buffers."
515 (with-current-buffer (get-buffer-create "*vc*")
516 (let ((default-directory dir)
517 (sticky-tag))
518 (erase-buffer)
519 (if (or (not name) (string= name ""))
520 (vc-mcvs-command t 0 nil "update")
521 (vc-mcvs-command t 0 nil "update" "-r" name)
522 (setq sticky-tag name))
523 (when update
524 (goto-char (point-min))
525 (while (not (eobp))
526 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
527 (let* ((file (expand-file-name (match-string 2) dir))
528 (state (match-string 1))
529 (buffer (find-buffer-visiting file)))
530 (when buffer
531 (cond
532 ((or (string= state "U")
533 (string= state "P"))
534 (vc-file-setprop file 'vc-state 'up-to-date)
535 (vc-file-setprop file 'vc-workfile-version nil)
536 (vc-file-setprop file 'vc-checkout-time
537 (nth 5 (file-attributes file))))
538 ((or (string= state "M")
539 (string= state "C"))
540 (vc-file-setprop file 'vc-state 'edited)
541 (vc-file-setprop file 'vc-workfile-version nil)
542 (vc-file-setprop file 'vc-checkout-time 0)))
543 (vc-file-setprop file 'vc-mcvs-sticky-tag sticky-tag)
544 (vc-resynch-buffer file t t))))
545 (forward-line 1))))))
546
547
548 ;;;
549 ;;; Miscellaneous
550 ;;;
551
552 (defalias 'vc-mcvs-make-version-backups-p 'vc-stay-local-p
553 "Return non-nil if version backups should be made for FILE.")
554 (defalias 'vc-mcvs-check-headers 'vc-cvs-check-headers)
555
556
557 ;;;
558 ;;; Internal functions
559 ;;;
560
561 (defun vc-mcvs-command (buffer okstatus file &rest flags)
562 "A wrapper around `vc-do-command' for use in vc-mcvs.el.
563 The difference to vc-do-command is that this function always invokes `mcvs',
564 and that it passes `vc-mcvs-global-switches' to it before FLAGS."
565 (let ((args (append '("--error-terminate")
566 (if (stringp vc-mcvs-global-switches)
567 (cons vc-mcvs-global-switches flags)
568 (append vc-mcvs-global-switches flags)))))
569 (if (not (member (car flags) '("diff" "log" "status")))
570 ;; No need to filter: do it the easy way.
571 (apply 'vc-do-command buffer okstatus "mcvs" file args)
572 ;; We need to filter the output.
573 ;; The output of the filter uses filenames relative to the root,
574 ;; so we need to change the default-directory.
575 ;; (assert (equal default-directory (vc-mcvs-root file)))
576 (vc-do-command
577 buffer okstatus "sh" nil "-c"
578 (concat "mcvs "
579 (mapconcat
580 'shell-quote-argument
581 (append (remq nil args)
582 (if file (list (file-relative-name file))))
583 " ")
584 " | mcvs filt")))))
585
586 (defun vc-mcvs-repository-hostname (dirname)
587 (vc-cvs-repository-hostname (vc-mcvs-root dirname)))
588
589 (defun vc-mcvs-dir-state-heuristic (dir)
590 "Find the Meta-CVS state of all files in DIR, using only local information."
591 (with-temp-buffer
592 (vc-cvs-get-entries dir)
593 (goto-char (point-min))
594 (while (not (eobp))
595 ;; Meta-MCVS-removed files are not taken under VC control.
596 (when (looking-at "/\\([^/]*\\)/[^/-]")
597 (let ((file (expand-file-name (match-string 1) dir)))
598 (unless (vc-file-getprop file 'vc-state)
599 (vc-cvs-parse-entry file t))))
600 (forward-line 1))))
601
602 (defalias 'vc-mcvs-valid-symbolic-tag-name-p 'vc-cvs-valid-symbolic-tag-name-p)
603 (defalias 'vc-mcvs-valid-version-number-p 'vc-cvs-valid-version-number-p)
604
605 (provide 'vc-mcvs)
606
607 ;; arch-tag: a39c7c1c-5247-429d-88df-dd7187d2e704
608 ;;; vc-mcvs.el ends here