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