1 ;;; vc-cvs.el --- non-resident support for CVS version-control -*- lexical-binding: t -*-
3 ;; Copyright (C) 1995, 1998-2016 Free Software Foundation, Inc.
5 ;; Author: FSF (see vc.el for full credits)
6 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
9 ;; This file is part of GNU Emacs.
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.
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.
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/>.
28 (eval-when-compile (require 'vc
))
30 ;; Clear up the cache to force vc-call to check again and discover
31 ;; new functions when we reload this file.
32 (put 'CVS
'vc-functions nil
)
34 ;;; Properties of the backend.
36 (defun vc-cvs-revision-granularity () 'file
)
38 (defun vc-cvs-checkout-model (files)
39 "CVS-specific version of `vc-checkout-model'."
40 (if (getenv "CVSREAD")
42 (let* ((file (if (consp files
) (car files
) files
))
43 (attrib (file-attributes file
)))
44 (or (vc-file-getprop file
'vc-checkout-model
)
46 file
'vc-checkout-model
47 (if (and attrib
;; don't check further if FILE doesn't exist
48 ;; If the file is not writable (despite CVSREAD being
49 ;; undefined), this is probably because the file is being
50 ;; "watched" by other developers.
51 ;; (We actually shouldn't trust this, but there is
52 ;; no other way to learn this from CVS at the
53 ;; moment (version 1.9).)
54 (string-match "r-..-..-." (nth 8 attrib
)))
59 ;;; Customization options
67 (defcustom vc-cvs-global-switches nil
68 "Global switches to pass to any CVS command."
69 :type
'(choice (const :tag
"None" nil
)
70 (string :tag
"Argument String")
71 (repeat :tag
"Argument List"
77 (defcustom vc-cvs-register-switches nil
78 "Switches for registering a file into CVS.
79 A string or list of strings passed to the checkin program by
80 \\[vc-register]. If nil, use the value of `vc-register-switches'.
81 If t, use no switches."
82 :type
'(choice (const :tag
"Unspecified" nil
)
84 (string :tag
"Argument String")
85 (repeat :tag
"Argument List" :value
("") string
))
89 (defcustom vc-cvs-diff-switches nil
90 "String or list of strings specifying switches for CVS diff under VC.
91 If nil, use the value of `vc-diff-switches'. If t, use no switches."
92 :type
'(choice (const :tag
"Unspecified" nil
)
94 (string :tag
"Argument String")
95 (repeat :tag
"Argument List" :value
("") string
))
99 (defcustom vc-cvs-annotate-switches nil
100 "String or list of strings specifying switches for cvs annotate under VC.
101 If nil, use the value of `vc-annotate-switches'. If t, use no
103 :type
'(choice (const :tag
"Unspecified" nil
)
104 (const :tag
"None" t
)
105 (string :tag
"Argument String")
106 (repeat :tag
"Argument List" :value
("") string
))
110 (defcustom vc-cvs-header
'("$Id\ $")
111 "Header keywords to be inserted by `vc-insert-headers'."
112 :version
"24.1" ; no longer consult the obsolete vc-header-alist
113 :type
'(repeat string
)
116 (defcustom vc-cvs-use-edit t
117 "Non-nil means to use `cvs edit' to \"check out\" a file.
118 This is only meaningful if you don't use the implicit checkout model
119 \(i.e. if you have $CVSREAD set)."
124 (defcustom vc-cvs-stay-local
'only-file
125 "Non-nil means use local operations when possible for remote repositories.
126 This avoids slow queries over the network and instead uses heuristics
127 and past information to determine the current status of a file.
129 If value is the symbol `only-file', `vc-dir' will connect to the
130 server, but heuristics will be used to determine the status for
131 all other VC operations.
133 The value can also be a regular expression or list of regular
134 expressions to match against the host name of a repository; then
135 vc-cvs only stays local for hosts that match it. Alternatively,
136 the value can be a list of regular expressions where the first
137 element is the symbol `except'; then vc-cvs always stays local
138 except for hosts matched by these regular expressions."
139 :type
'(choice (const :tag
"Always stay local" t
)
140 (const :tag
"Only for file operations" only-file
)
141 (const :tag
"Don't stay local" nil
)
142 (list :format
"\nExamine hostname and %v"
143 :tag
"Examine hostname ..."
144 (set :format
"%v" :inline t
145 (const :format
"%t" :tag
"don't" except
))
146 (regexp :format
" stay local,\n%t: %v"
147 :tag
"if it matches")
148 (repeat :format
"%v%i\n" :inline t
(regexp :tag
"or"))))
152 (defcustom vc-cvs-sticky-date-format-string
"%c"
153 "Format string for mode-line display of sticky date.
154 Format is according to `format-time-string'. Only used if
155 `vc-cvs-sticky-tag-display' is t."
160 (defcustom vc-cvs-sticky-tag-display t
161 "Specify the mode-line display of sticky tags.
162 Value t means default display, nil means no display at all. If the
163 value is a function or macro, it is called with the sticky tag and
164 its type as parameters, in that order. TYPE can have three different
165 values: `symbolic-name' (TAG is a string), `revision-number' (TAG is a
166 string) and `date' (TAG is a date as returned by `encode-time'). The
167 return value of the function or macro will be displayed as a string.
169 Here's an example that will display the formatted date for sticky
170 dates and the word \"Sticky\" for sticky tag names and revisions.
173 (cond ((eq type \\='date) (format-time-string
174 vc-cvs-sticky-date-format-string tag))
175 ((eq type \\='revision-number) \"Sticky\")
176 ((eq type \\='symbolic-name) \"Sticky\")))
178 Here's an example that will abbreviate to the first character only,
179 any text before the first occurrence of `-' for sticky symbolic tags.
180 If the sticky tag is a revision number, the word \"Sticky\" is
181 displayed. Date and time is displayed for sticky dates.
184 (cond ((eq type \\='date) (format-time-string \"%Y%m%d %H:%M\" tag))
185 ((eq type \\='revision-number) \"Sticky\")
186 ((eq type \\='symbolic-name)
189 (string-match \"\\\\([^-]*\\\\)\\\\(.*\\\\)\" tag)
190 (concat (substring (match-string 1 tag) 0 1) \":\"
191 (substring (match-string 2 tag) 1 nil)))
192 (error tag))))) ; Fall-back to given tag name.
194 See also variable `vc-cvs-sticky-date-format-string'."
195 :type
'(choice boolean function
)
200 ;;; Internal variables
205 ;;; State-querying functions
208 ;;;###autoload(defun vc-cvs-registered (f)
209 ;;;###autoload "Return non-nil if file F is registered with CVS."
210 ;;;###autoload (when (file-readable-p (expand-file-name
211 ;;;###autoload "CVS/Entries" (file-name-directory f)))
212 ;;;###autoload (load "vc-cvs" nil t)
213 ;;;###autoload (vc-cvs-registered f)))
215 (defun vc-cvs-registered (file)
216 "Check if FILE is CVS registered."
217 (let ((dirname (or (file-name-directory file
) ""))
218 (basename (file-name-nondirectory file
))
219 ;; make sure that the file name is searched case-sensitively
220 (case-fold-search nil
))
221 (if (file-readable-p (expand-file-name "CVS/Entries" dirname
))
222 (or (string= basename
"")
224 (vc-cvs-get-entries dirname
)
225 (goto-char (point-min))
226 (cond ((re-search-forward
227 (concat "^/" (regexp-quote basename
) "/[^/]") nil t
)
229 (vc-cvs-parse-entry file
)
234 (defun vc-cvs-state (file)
235 "CVS-specific version of `vc-state'."
236 (if (vc-cvs-stay-local-p file
)
237 (let ((state (vc-file-getprop file
'vc-state
)))
238 ;; If we should stay local, use the heuristic but only if
239 ;; we don't have a more precise state already available.
240 (if (memq state
'(up-to-date edited nil
))
241 (vc-cvs-state-heuristic file
)
244 (cd (file-name-directory file
))
245 (let (process-file-side-effects)
246 (vc-cvs-command t
0 file
"status"))
247 (vc-cvs-parse-status t
))))
249 (defun vc-cvs-state-heuristic (file)
250 "CVS-specific state heuristic."
251 ;; If the file has not changed since checkout, consider it `up-to-date'.
252 ;; Otherwise consider it `edited'.
253 (let ((checkout-time (vc-file-getprop file
'vc-checkout-time
))
254 (lastmod (nth 5 (file-attributes file
))))
256 ((equal checkout-time lastmod
) 'up-to-date
)
257 ((string= (vc-working-revision file
) "0") 'added
)
258 ((null checkout-time
) 'unregistered
)
261 (defun vc-cvs-working-revision (file)
262 "CVS-specific version of `vc-working-revision'."
263 ;; There is no need to consult RCS headers under CVS, because we
264 ;; get the workfile version for free when we recognize that a file
265 ;; is registered in CVS.
266 (vc-cvs-registered file
)
267 (vc-file-getprop file
'vc-working-revision
))
269 (defun vc-cvs-mode-line-string (file)
270 "Return a string for `vc-mode-line' to put in the mode line for FILE.
271 Compared to the default implementation, this function does two things:
272 Handle the special case of a CVS file that is added but not yet
273 committed and support display of sticky tags."
274 (let* ((sticky-tag (vc-file-getprop file
'vc-cvs-sticky-tag
))
277 (let ((def-ml (vc-default-mode-line-string 'CVS file
)))
279 (get-text-property 0 'help-echo def-ml
))
282 (if (zerop (length sticky-tag
))
284 (setq help-echo
(format-message "%s on the `%s' branch"
285 help-echo sticky-tag
))
286 (concat string
"[" sticky-tag
"]"))
287 'help-echo help-echo
)))
291 ;;; State-changing functions
294 (autoload 'vc-switches
"vc")
296 (defun vc-cvs-register (files &optional comment
)
297 "Register FILES into the CVS version-control system.
298 COMMENT can be used to provide an initial description of FILES.
299 Passes either `vc-cvs-register-switches' or `vc-register-switches'
301 ;; Register the directories if needed.
304 (and (not (vc-cvs-responsible-p file
))
305 (vc-cvs-could-register file
)
306 (push (directory-file-name (file-name-directory file
)) dirs
)))
307 (if dirs
(vc-cvs-register dirs
)))
308 (apply 'vc-cvs-command nil
0 files
310 (and comment
(string-match "[^\t\n ]" comment
)
311 (concat "-m" comment
))
312 (vc-switches 'CVS
'register
)))
314 (defun vc-cvs-responsible-p (file)
315 "Return non-nil if CVS thinks it is responsible for FILE."
316 (file-directory-p (expand-file-name "CVS"
317 (if (file-directory-p file
)
319 (file-name-directory file
)))))
321 (defun vc-cvs-could-register (file)
322 "Return non-nil if FILE could be registered in CVS.
323 This is only possible if CVS is managing FILE's directory or one of
326 (while (and (stringp dir
)
327 (not (equal dir
(setq dir
(file-name-directory dir
))))
329 (setq dir
(if (file-exists-p
330 (expand-file-name "CVS/Entries" dir
))
332 (directory-file-name dir
))))
335 (defun vc-cvs-checkin (files comment
&optional rev
)
336 "CVS-specific version of `vc-backend-checkin'."
337 (unless (or (not rev
) (vc-cvs-valid-revision-number-p rev
))
338 (if (not (vc-cvs-valid-symbolic-tag-name-p rev
))
339 (error "%s is not a valid symbolic tag name" rev
)
340 ;; If the input revision is a valid symbolic tag name, we create it
341 ;; as a branch, commit and switch to it.
342 (apply 'vc-cvs-command nil
0 files
"tag" "-b" (list rev
))
343 (apply 'vc-cvs-command nil
0 files
"update" "-r" (list rev
))
344 (mapc (lambda (file) (vc-file-setprop file
'vc-cvs-sticky-tag rev
))
346 (let ((status (apply 'vc-cvs-command nil
1 files
347 "ci" (if rev
(concat "-r" rev
))
348 (concat "-m" comment
)
349 (vc-switches 'CVS
'checkin
))))
351 (goto-char (point-min))
352 (when (not (zerop status
))
353 ;; Check checkin problem.
355 ((re-search-forward "Up-to-date check failed" nil t
)
356 (mapc (lambda (file) (vc-file-setprop file
'vc-state
'needs-merge
))
358 (error "%s" (substitute-command-keys
359 (concat "Up-to-date check failed: "
360 "type \\[vc-next-action] to merge in changes"))))
362 (pop-to-buffer (current-buffer))
363 (goto-char (point-min))
364 (shrink-window-if-larger-than-buffer)
365 (error "Check-in failed"))))
366 ;; Single-file commit? Then update the revision by parsing the buffer.
367 ;; Otherwise we can't necessarily tell what goes with what; clear
368 ;; its properties so they have to be refetched.
369 (if (= (length files
) 1)
371 (car files
) 'vc-working-revision
372 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
373 (mapc 'vc-file-clearprops files
))
374 ;; Anyway, forget the checkout model of the file, because we might have
375 ;; guessed wrong when we found the file. After commit, we can
376 ;; tell it from the permissions of the file (see
377 ;; vc-cvs-checkout-model).
378 (mapc (lambda (file) (vc-file-setprop file
'vc-checkout-model nil
))
380 ;; if this was an explicit check-in (does not include creation of
381 ;; a branch), remove the sticky tag.
382 (if (and rev
(not (vc-cvs-valid-symbolic-tag-name-p rev
)))
383 (vc-cvs-command nil
0 files
"update" "-A"))))
385 (defun vc-cvs-find-revision (file rev buffer
)
386 (apply 'vc-cvs-command
388 "-Q" ; suppress diagnostic output
390 (and rev
(not (string= rev
""))
393 (vc-switches 'CVS
'checkout
)))
395 (defun vc-cvs-checkout (file &optional rev
)
396 "Checkout a revision of FILE into the working area.
397 REV is the revision to check out."
398 (message "Checking out %s..." file
)
399 ;; Change buffers to get local value of vc-checkout-switches.
400 (with-current-buffer (or (get-file-buffer file
) (current-buffer))
401 (if (and (file-exists-p file
) (not rev
))
402 ;; If no revision was specified, just make the file writable
403 ;; if necessary (using `cvs-edit' if requested).
404 (and (not (eq (vc-cvs-checkout-model (list file
)) 'implicit
))
406 (vc-cvs-command nil
0 file
"edit")
407 (set-file-modes file
(logior (file-modes file
) 128))
408 (if (equal file buffer-file-name
) (read-only-mode -
1))))
409 ;; Check out a particular revision (or recreate the file).
410 (vc-file-setprop file
'vc-working-revision nil
)
411 (apply 'vc-cvs-command nil
0 file
416 ;; default for verbose checkout: clear the
417 ;; sticky tag so that the actual update will
418 ;; get the head of the trunk
422 (vc-switches 'CVS
'checkout
)))
423 (vc-mode-line file
'CVS
))
424 (message "Checking out %s...done" file
))
426 (defun vc-cvs-delete-file (file)
427 (vc-cvs-command nil
0 file
"remove" "-f"))
429 (autoload 'vc-default-revert
"vc")
431 (defun vc-cvs-revert (file &optional contents-done
)
432 "Revert FILE to the working revision on which it was based."
433 (vc-default-revert 'CVS file contents-done
)
434 (unless (eq (vc-cvs-checkout-model (list file
)) 'implicit
)
436 (vc-cvs-command nil
0 file
"unedit")
437 ;; Make the file read-only by switching off all w-bits
438 (set-file-modes file
(logand (file-modes file
) 3950)))))
440 (defun vc-cvs-merge-file (file)
441 "Accept a file merge request, prompting for revisions."
442 (let* ((first-revision
444 (concat "Merge " file
445 " from branch or revision "
446 "(default news on current branch): ")
452 ((string= first-revision
"")
453 (setq status
(vc-cvs-merge-news file
)))
455 (if (not (vc-branch-p first-revision
))
456 (setq second-revision
460 (concat (vc-branch-part first-revision
) ".")))
461 ;; We want to merge an entire branch. Set revisions
462 ;; accordingly, so that vc-cvs-merge understands us.
463 (setq second-revision first-revision
)
464 ;; first-revision must be the starting point of the branch
465 (setq first-revision
(vc-branch-part first-revision
)))
466 (setq status
(vc-cvs-merge file first-revision second-revision
))))
469 (defun vc-cvs-merge (file first-revision
&optional second-revision
)
470 "Merge changes into current working copy of FILE.
471 The changes are between FIRST-REVISION and SECOND-REVISION."
472 (vc-cvs-command nil
0 file
474 (concat "-j" first-revision
)
475 (concat "-j" second-revision
))
476 (vc-file-setprop file
'vc-state
'edited
)
477 (with-current-buffer (get-buffer "*vc*")
478 (goto-char (point-min))
479 (if (re-search-forward "conflicts during merge" nil t
)
481 (vc-file-setprop file
'vc-state
'conflict
)
484 (vc-file-setprop file
'vc-state
'edited
)
488 (defun vc-cvs-merge-news (file)
489 "Merge in any new changes made to FILE."
490 (message "Merging changes into %s..." file
)
491 ;; (vc-file-setprop file 'vc-working-revision nil)
492 (vc-file-setprop file
'vc-checkout-time
0)
493 (vc-cvs-command nil nil file
"update")
494 ;; Analyze the merge result reported by CVS, and set
495 ;; file properties accordingly.
496 (with-current-buffer (get-buffer "*vc*")
497 (goto-char (point-min))
498 ;; get new working revision
499 (if (re-search-forward
500 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t
)
501 (vc-file-setprop file
'vc-working-revision
(match-string 1))
502 (vc-file-setprop file
'vc-working-revision nil
))
505 (if (eq (buffer-size) 0)
506 0 ;; there were no news; indicate success
507 (if (re-search-forward
508 (concat "^\\([CMUP] \\)?"
510 (substring file
(1+ (length (expand-file-name
511 "." default-directory
)))))
512 "\\( already contains the differences between \\)?")
515 ;; Merge successful, we are in sync with repository now
516 ((or (match-string 2)
517 (string= (match-string 1) "U ")
518 (string= (match-string 1) "P "))
519 (vc-file-setprop file
'vc-state
'up-to-date
)
520 (vc-file-setprop file
'vc-checkout-time
521 (nth 5 (file-attributes file
)))
522 0);; indicate success to the caller
523 ;; Merge successful, but our own changes are still in the file
524 ((string= (match-string 1) "M ")
525 (vc-file-setprop file
'vc-state
'edited
)
526 0);; indicate success to the caller
527 ;; Conflicts detected!
529 (vc-file-setprop file
'vc-state
'conflict
)
530 1);; signal the error to the caller
532 (pop-to-buffer "*vc*")
533 (error "Couldn't analyze cvs update result")))
534 (message "Merging changes into %s...done" file
))))
536 (defun vc-cvs-modify-change-comment (files rev comment
)
537 "Modify the change comments for FILES on a specified REV.
538 Will fail unless you have administrative privileges on the repo."
539 (vc-cvs-command nil
0 files
"admin" (concat "-m" rev
":" comment
)))
542 ;;; History functions
545 (declare-function vc-rcs-print-log-cleanup
"vc-rcs" ())
546 ;; Follows vc-cvs-command, which uses vc-do-command from vc-dispatcher.
547 (declare-function vc-exec-after
"vc-dispatcher" (code))
549 (defun vc-cvs-print-log (files buffer
&optional _shortlog _start-revision limit
)
550 "Print commit log associated with FILES into specified BUFFER.
551 Remaining arguments are ignored."
553 ;; It's just the catenation of the individual logs.
556 (if (vc-cvs-stay-local-p files
) 'async
0)
558 (with-current-buffer buffer
559 (vc-run-delayed (vc-rcs-print-log-cleanup)))
560 (when limit
'limit-unsupported
))
562 (defun vc-cvs-comment-history (file)
563 "Get comment history of a file."
564 (vc-call-backend 'RCS
'comment-history file
))
566 (autoload 'vc-version-backup-file
"vc")
567 (declare-function vc-coding-system-for-diff
"vc" (file))
569 (defun vc-cvs-diff (files &optional oldvers newvers buffer async
)
570 "Get a difference report using CVS between two revisions of FILE."
571 (let* (process-file-side-effects
572 (async (and async
(vc-cvs-stay-local-p files
)))
573 (invoke-cvs-diff-list nil
)
575 ;; Look through the file list and see if any files have backups
576 ;; that can be used to do a plain "diff" instead of "cvs diff".
580 (when (or (not ov
) (string-equal ov
""))
581 (setq ov
(vc-working-revision file
)))
582 (when (string-equal nv
"")
584 (let ((file-oldvers (vc-version-backup-file file ov
))
585 (file-newvers (if (not nv
)
587 (vc-version-backup-file file nv
)))
588 (coding-system-for-read (vc-coding-system-for-diff file
)))
589 (if (and file-oldvers file-newvers
)
591 ;; This used to append diff-switches and vc-diff-switches,
592 ;; which was consistent with the vc-diff-switches doc at that
593 ;; time, but not with the actual behavior of any other VC diff.
594 (apply 'vc-do-command
(or buffer
"*vc-diff*") 1 "diff" nil
595 ;; Not a CVS diff, does not use vc-cvs-diff-switches.
596 (append (vc-switches nil
'diff
)
597 (list (file-relative-name file-oldvers
)
598 (file-relative-name file-newvers
))))
600 (push file invoke-cvs-diff-list
)))))
601 (when invoke-cvs-diff-list
602 (setq status
(apply 'vc-cvs-command
(or buffer
"*vc-diff*")
604 invoke-cvs-diff-list
"diff"
605 (and oldvers
(concat "-r" oldvers
))
606 (and newvers
(concat "-r" newvers
))
607 (vc-switches 'CVS
'diff
))))
608 (if async
1 status
))) ; async diff, pessimistic assumption
610 (defconst vc-cvs-annotate-first-line-re
"^[0-9]")
612 (defun vc-cvs-annotate-process-filter (filter process string
)
613 (setq string
(concat (process-get process
'output
) string
))
614 (if (not (string-match vc-cvs-annotate-first-line-re string
))
615 ;; Still waiting for the first real line.
616 (process-put process
'output string
)
617 (remove-function (process-filter process
) #'vc-cvs-annotate-process-filter
)
618 (funcall filter process
(substring string
(match-beginning 0)))))
620 (defun vc-cvs-annotate-command (file buffer
&optional revision
)
621 "Execute \"cvs annotate\" on FILE, inserting the contents in BUFFER.
622 Optional arg REVISION is a revision to annotate from."
623 (apply #'vc-cvs-command buffer
624 (if (vc-cvs-stay-local-p file
)
627 (append (vc-switches 'cvs
'annotate
)
628 (if revision
(list (concat "-r" revision
)))))
629 ;; Strip the leading few lines.
630 (let ((proc (get-buffer-process buffer
)))
632 ;; If running asynchronously, use a process filter.
633 (add-function :around
(process-filter proc
)
634 #'vc-cvs-annotate-process-filter
)
635 (with-current-buffer buffer
636 (goto-char (point-min))
637 (re-search-forward vc-cvs-annotate-first-line-re
)
638 (delete-region (point-min) (1- (point)))))))
640 (declare-function vc-annotate-convert-time
"vc-annotate" (&optional time
))
642 (defun vc-cvs-annotate-current-time ()
643 "Return the current time, based at midnight of the current day, and
644 encoded as fractional days."
645 (vc-annotate-convert-time
646 (apply 'encode-time
0 0 0 (nthcdr 3 (decode-time)))))
648 (defun vc-cvs-annotate-time ()
649 "Return the time of the next annotation (as fraction of days)
650 systime, or nil if there is none."
652 (cache (get-text-property bol
'vc-cvs-annotate-time
))
653 (inhibit-read-only t
)
654 (inhibit-modification-hooks t
))
658 "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): ")
659 (let ((day (string-to-number (match-string 1)))
660 (month (cdr (assq (intern (match-string 2))
661 '((Jan .
1) (Feb .
2) (Mar .
3)
662 (Apr .
4) (May .
5) (Jun .
6)
663 (Jul .
7) (Aug .
8) (Sep .
9)
664 (Oct .
10) (Nov .
11) (Dec .
12)))))
665 (year (let ((tmp (string-to-number (match-string 3))))
666 ;; Years 0..68 are 2000..2068.
667 ;; Years 69..99 are 1969..1999.
668 (+ (cond ((> 69 tmp
) 2000)
673 bol
(1+ bol
) 'vc-cvs-annotate-time
675 ;; Position at end makes for nicer overlay result.
676 ;; Don't put actual buffer pos here, but only relative
677 ;; distance, so we don't ever move backward in the
678 ;; goto-char below, even if the text is moved.
679 (- (match-end 0) (match-beginning 0))
680 (vc-annotate-convert-time
681 (encode-time 0 0 0 day month year
))))))))
683 (goto-char (+ bol
(car cache
))) ; Fontify from here to eol.
684 (cdr cache
)))) ; days (float)
686 (defun vc-cvs-annotate-extract-revision-at-line ()
689 (if (re-search-forward "^\\([0-9]+\\.[0-9]+\\(\\.[0-9]+\\)*\\) +("
690 (line-end-position) t
)
691 (match-string-no-properties 1)
694 (defun vc-cvs-previous-revision (file rev
)
695 (vc-call-backend 'RCS
'previous-revision file rev
))
697 (defun vc-cvs-next-revision (file rev
)
698 (vc-call-backend 'RCS
'next-revision file rev
))
700 ;; FIXME: This should probably be replaced by code using cvs2cl.
701 (defun vc-cvs-update-changelog (files)
702 (vc-call-backend 'RCS
'update-changelog files
))
708 (defun vc-cvs-create-tag (dir name branchp
)
709 "Assign to DIR's current revision a given NAME.
710 If BRANCHP is non-nil, the name is created as a branch (and the current
711 workspace is immediately moved to that new branch)."
712 (vc-cvs-command nil
0 dir
"tag" "-c" (if branchp
"-b") name
)
713 (when branchp
(vc-cvs-command nil
0 dir
"update" "-r" name
)))
715 ;; Follows vc-cvs-command, which uses vc-do-command from vc-dispatcher.
716 (declare-function vc-resynch-buffer
"vc-dispatcher"
717 (file &optional keep noquery reset-vc-info
))
719 (defun vc-cvs-retrieve-tag (dir name update
)
720 "Retrieve a tag at and below DIR.
721 NAME is the name of the tag; if it is empty, do a `cvs update'.
722 If UPDATE is non-nil, then update (resynch) any affected buffers."
723 (with-current-buffer (get-buffer-create "*vc*")
724 (let ((default-directory dir
)
727 (if (or (not name
) (string= name
""))
728 (vc-cvs-command t
0 nil
"update")
729 (vc-cvs-command t
0 nil
"update" "-r" name
)
730 (setq sticky-tag name
))
732 (goto-char (point-min))
734 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
735 (let* ((file (expand-file-name (match-string 2) dir
))
736 (state (match-string 1))
737 (buffer (find-buffer-visiting file
)))
740 ((or (string= state
"U")
742 (vc-file-setprop file
'vc-state
'up-to-date
)
743 (vc-file-setprop file
'vc-working-revision nil
)
744 (vc-file-setprop file
'vc-checkout-time
745 (nth 5 (file-attributes file
))))
746 ((or (string= state
"M")
748 (vc-file-setprop file
'vc-state
'edited
)
749 (vc-file-setprop file
'vc-working-revision nil
)
750 (vc-file-setprop file
'vc-checkout-time
0)))
751 (vc-file-setprop file
'vc-cvs-sticky-tag sticky-tag
)
752 (vc-resynch-buffer file t t
))))
753 (forward-line 1))))))
760 (defun vc-cvs-make-version-backups-p (file)
761 "Return non-nil if version backups should be made for FILE."
762 (vc-cvs-stay-local-p file
))
764 (defun vc-cvs-check-headers ()
765 "Check if the current file has any headers in it."
767 (goto-char (point-min))
768 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
769 \\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t
)))
773 ;;; Internal functions
776 (defun vc-cvs-command (buffer okstatus files
&rest flags
)
777 "A wrapper around `vc-do-command' for use in vc-cvs.el.
778 The difference to vc-do-command is that this function always invokes `cvs',
779 and that it passes `vc-cvs-global-switches' to it before FLAGS."
780 (apply 'vc-do-command
(or buffer
"*vc*") okstatus
"cvs" files
781 (if (stringp vc-cvs-global-switches
)
782 (cons vc-cvs-global-switches flags
)
783 (append vc-cvs-global-switches
786 (defun vc-cvs-stay-local-p (file)
787 "Return non-nil if VC should stay local when handling FILE.
788 If FILE is a list of files, return non-nil if any of them
789 individually should stay local."
791 (delq nil
(mapcar (lambda (arg) (vc-cvs-stay-local-p arg
)) file
))
792 (let ((stay-local vc-cvs-stay-local
))
793 (if (symbolp stay-local
) stay-local
794 (let ((dirname (if (file-directory-p file
)
795 (directory-file-name file
)
796 (file-name-directory file
))))
798 (or (vc-file-getprop dirname
'vc-cvs-stay-local-p
)
800 dirname
'vc-cvs-stay-local-p
801 (let ((hostname (vc-cvs-repository-hostname dirname
)))
805 (if (eq (car-safe stay-local
) 'except
)
806 (setq default nil stay-local
(cdr stay-local
)))
807 (when (consp stay-local
)
809 (mapconcat 'identity stay-local
"\\|")))
810 (if (if (string-match stay-local hostname
)
811 default
(not default
))
814 (defun vc-cvs-repository-hostname (dirname)
815 "Hostname of the CVS server associated to workarea DIRNAME."
816 (let ((rootname (expand-file-name "CVS/Root" dirname
)))
817 (when (file-readable-p rootname
)
819 (let ((coding-system-for-read
820 (or file-name-coding-system
821 default-file-name-coding-system
)))
822 (vc-insert-file rootname
))
823 (goto-char (point-min))
824 (nth 2 (vc-cvs-parse-root
825 (buffer-substring (point)
826 (line-end-position))))))))
828 (defun vc-cvs-parse-uhp (path)
829 "parse user@host/path into (user@host /path)"
830 (if (string-match "\\([^/]+\\)\\(/.*\\)" path
)
831 (list (match-string 1 path
) (match-string 2 path
))
834 (defun vc-cvs-parse-root (root)
835 "Split CVS ROOT specification string into a list of fields.
836 A CVS root specification of the form
837 [:METHOD:][[USER@]HOSTNAME]:?/path/to/repository
838 is converted to a normalized record with the following structure:
839 \(METHOD USER HOSTNAME CVS-ROOT).
840 The default METHOD for a CVS root of the form
843 The default METHOD for a CVS root of the form
844 [USER@]HOSTNAME:/path/to/repository
846 For an empty string, nil is returned (invalid CVS root)."
847 ;; Split CVS root into colon separated fields (0-4).
848 ;; The `x:' makes sure, that leading colons are not lost;
849 ;; `HOST:/PATH' is then different from `:METHOD:/PATH'.
850 (let* ((root-list (cdr (split-string (concat "x:" root
) ":")))
851 (len (length root-list
))
852 ;; All syntactic varieties will get a proper METHOD.
859 (let ((uhp (vc-cvs-parse-uhp (car root-list
))))
860 (cons (if (car uhp
) "ext" "local") uhp
)))
862 ;; [USER@]HOST:PATH => method `ext'
863 (and (not (equal (car root-list
) ""))
864 (cons "ext" root-list
)))
866 ;; :METHOD:PATH or :METHOD:USER@HOSTNAME/PATH
867 (cons (cadr root-list
)
868 (vc-cvs-parse-uhp (nth 2 root-list
))))
870 ;; :METHOD:[USER@]HOST:PATH
873 (let ((method (car root-list
))
874 (uhost (or (cadr root-list
) ""))
875 (root (nth 2 root-list
))
878 (if (string-match "\\(.*\\)@\\(.*\\)" uhost
)
879 (setq user
(match-string 1 uhost
)
880 host
(match-string 2 uhost
))
885 ;; Fix windows style CVS root `:local:C:\\project\\cvs\\some\\dir'
887 (equal method
"local")
888 (setq root
(concat host
":" root
) host nil
))
889 ;; Normalize CVS root record
890 (list method user host root
)))))
892 ;; XXX: This does not work correctly for subdirectories. "cvs status"
893 ;; information is context sensitive, it contains lines like:
894 ;; cvs status: Examining DIRNAME
895 ;; and the file entries after that don't show the full path.
896 ;; Because of this VC directory listings only show changed files
897 ;; at the top level for CVS.
898 (defun vc-cvs-parse-status (&optional full
)
899 "Parse output of \"cvs status\" command in the current buffer.
900 Set file properties accordingly. Unless FULL is t, parse only
901 essential information. Note that this can never set the `ignored'
903 (let (file status missing
)
904 (goto-char (point-min))
905 (while (looking-at "? \\(.*\\)")
906 (setq file
(expand-file-name (match-string 1)))
907 (vc-file-setprop file
'vc-state
'unregistered
)
909 (when (re-search-forward "^File: " nil t
)
910 (when (setq missing
(looking-at "no file "))
911 (goto-char (match-end 0)))
913 ((re-search-forward "\\=\\([^ \t]+\\)" nil t
)
914 (setq file
(expand-file-name (match-string 1)))
915 (setq status
(if (re-search-forward "\\=[ \t]+Status: \\(.*\\)" nil t
)
916 (match-string 1) "Unknown"))
919 "\\(RCS Version\\|RCS Revision\\|Repository revision\\):\
922 (vc-file-setprop file
'vc-latest-revision
(match-string 2)))
926 ((string-match "Up-to-date" status
)
927 (vc-file-setprop file
'vc-checkout-time
928 (nth 5 (file-attributes file
)))
930 ((string-match "Locally Modified" status
) 'edited
)
931 ((string-match "Needs Merge" status
) 'needs-merge
)
932 ((string-match "Needs \\(Checkout\\|Patch\\)" status
)
933 (if missing
'missing
'needs-update
))
934 ((string-match "Locally Added" status
) 'added
)
935 ((string-match "Locally Removed" status
) 'removed
)
936 ((string-match "File had conflicts " status
) 'conflict
)
937 ((string-match "Unknown" status
) 'unregistered
)
940 (defun vc-cvs-after-dir-status (update-function)
941 ;; Heavily inspired by vc-cvs-parse-status. AKA a quick hack.
942 ;; This needs a lot of testing.
949 (subdir default-directory
))
950 (goto-char (point-min))
952 ;; Look for either a file entry, an unregistered file, or a
955 "\\(^=+\n\\([^=c?\n].*\n\\|\n\\)+\\)\\|\\(\\(^?? .*\n\\)+\\)\\|\\(^cvs status: \\(Examining\\|nothing\\) .*\n\\)"
957 ;; FIXME: get rid of narrowing here.
958 (narrow-to-region (match-beginning 0) (match-end 0))
959 (goto-char (point-min))
961 (when (looking-at "cvs status: Examining \\(.+\\)")
962 (setq subdir
(expand-file-name (match-string 1))))
963 ;; Unregistered files
964 (while (looking-at "? \\(.*\\)")
965 (setq file
(file-relative-name
966 (expand-file-name (match-string 1) subdir
)))
967 (push (list file
'unregistered
) result
)
969 (when (looking-at "cvs status: nothing known about")
970 ;; We asked about a non existent file. The output looks like this:
972 ;; cvs status: nothing known about `lisp/v.diff'
973 ;; ===================================================================
974 ;; File: no file v.diff Status: Unknown
976 ;; Working revision: No entry for v.diff
977 ;; Repository revision: No revision control file
980 ;; Due to narrowing in this iteration we only see the "cvs
981 ;; status:" line, so just set a flag so that we can ignore the
982 ;; file in the next iteration.
983 (setq ignore-next t
))
985 (when (re-search-forward "^File: \\(no file \\)?\\(.*[^ \t]\\)[ \t]+Status: \\(.*\\)" nil t
)
986 (setq missing
(match-string 1))
987 (setq file
(file-relative-name
988 (expand-file-name (match-string 2) subdir
)))
989 (setq status-str
(match-string 3))
992 ((string-match "Up-to-date" status-str
) 'up-to-date
)
993 ((string-match "Locally Modified" status-str
) 'edited
)
994 ((string-match "Needs Merge" status-str
) 'needs-merge
)
995 ((string-match "Needs \\(Checkout\\|Patch\\)" status-str
)
996 (if missing
'missing
'needs-update
))
997 ((string-match "Locally Added" status-str
) 'added
)
998 ((string-match "Locally Removed" status-str
) 'removed
)
999 ((string-match "File had conflicts " status-str
) 'conflict
)
1000 ((string-match "Unknown" status-str
) 'unregistered
)
1003 (setq ignore-next nil
)
1004 (unless (eq status
'up-to-date
)
1005 (push (list file status
) result
))))
1006 (goto-char (point-max))
1008 (funcall update-function result
))
1009 ;; Alternative implementation: use the "update" command instead of
1010 ;; the "status" command.
1011 ;; (let ((result nil)
1012 ;; (translation '((?? . unregistered)
1016 ;; (?P . needs-merge)
1018 ;; (?U . needs-update))))
1019 ;; (goto-char (point-min))
1020 ;; (while (not (eobp))
1021 ;; (if (looking-at "^[ACMPRU?] \\(.*\\)$")
1022 ;; (push (list (match-string 1)
1023 ;; (cdr (assoc (char-after) translation)))
1026 ;; ((looking-at "cvs update: warning: \\(.*\\) was lost")
1028 ;; ;; cvs update: warning: FILENAME was lost
1030 ;; (push (list (match-string 1) 'missing) result)
1031 ;; ;; Skip the "U" line
1032 ;; (forward-line 1))
1033 ;; ((looking-at "cvs update: New directory `\\(.*\\)' -- ignored")
1034 ;; (push (list (match-string 1) 'unregistered) result))))
1035 ;; (forward-line 1))
1036 ;; (funcall update-function result)))
1039 ;; Based on vc-cvs-dir-state-heuristic from Emacs 22.
1040 ;; FIXME does not mention unregistered files.
1041 (defun vc-cvs-dir-status-heuristic (dir update-function
&optional basedir
)
1042 "Find the CVS state of all files in DIR, using only local information."
1043 (let (file basename status result dirlist
)
1045 (vc-cvs-get-entries dir
)
1046 (goto-char (point-min))
1048 (if (looking-at "D/\\([^/]*\\)////")
1049 (push (expand-file-name (match-string 1) dir
) dirlist
)
1050 ;; CVS-removed files are not taken under VC control.
1051 (when (looking-at "/\\([^/]*\\)/[^/-]")
1052 (setq basename
(match-string 1)
1053 file
(expand-file-name basename dir
)
1054 status
(or (vc-file-getprop file
'vc-state
)
1055 (vc-cvs-parse-entry file t
)))
1056 (unless (eq status
'up-to-date
)
1057 (push (list (if basedir
1058 (file-relative-name file basedir
)
1062 (dolist (subdir dirlist
)
1063 (setq result
(append result
1064 (vc-cvs-dir-status-heuristic subdir nil
1065 (or basedir dir
)))))
1067 (funcall update-function result
))))
1069 (defun vc-cvs-dir-status-files (dir files update-function
)
1070 "Create a list of conses (file . state) for FILES in DIR.
1071 Query all files in DIR if files is nil."
1072 (let ((local (vc-cvs-stay-local-p dir
)))
1073 (if (and (not files
) local
(not (eq local
'only-file
)))
1074 (vc-cvs-dir-status-heuristic dir update-function
)
1075 (if (not files
) (setq files
(vc-expand-dirs (list dir
) 'CVS
)))
1076 (vc-cvs-command (current-buffer) 'async files
"-f" "status")
1077 ;; Alternative implementation: use the "update" command instead of
1078 ;; the "status" command.
1079 ;; (vc-cvs-command (current-buffer) 'async
1080 ;; (file-relative-name dir)
1081 ;; "-f" "-n" "update" "-d" "-P")
1083 (vc-cvs-after-dir-status update-function
)))))
1085 (defun vc-cvs-file-to-string (file)
1086 "Read the content of FILE and return it as a string."
1089 (insert-file-contents file
)
1090 (goto-char (point-min))
1091 (buffer-substring (point) (point-max)))
1094 (defun vc-cvs-dir-extra-headers (_dir)
1095 "Extract and represent per-directory properties of a CVS working copy."
1099 (insert-file-contents "CVS/Root")
1100 (goto-char (point-min))
1101 (and (looking-at ":ext:") (delete-char 5))
1102 (concat (buffer-substring (point) (1- (point-max))) "\n"))
1107 (insert-file-contents "CVS/Repository")
1108 (goto-char (point-min))
1109 (skip-chars-forward "^\n")
1110 (concat (buffer-substring (point-min) (point)) "\n"))
1114 (concat (propertize "Repository : " 'face
'font-lock-type-face
)
1115 (propertize repo
'face
'font-lock-variable-name-face
)))
1118 (concat (propertize "Module : " 'face
'font-lock-type-face
)
1119 (propertize module
'face
'font-lock-variable-name-face
)))
1121 (if (file-readable-p "CVS/Tag")
1122 (let ((tag (vc-cvs-file-to-string "CVS/Tag")))
1124 ((string-match "\\`T" tag
)
1125 (concat (propertize "Tag : " 'face
'font-lock-type-face
)
1126 (propertize (substring tag
1)
1127 'face
'font-lock-variable-name-face
)))
1128 ((string-match "\\`D" tag
)
1129 (concat (propertize "Date : " 'face
'font-lock-type-face
)
1130 (propertize (substring tag
1)
1131 'face
'font-lock-variable-name-face
)))
1134 ;; In CVS, branch is a per-file property, not a per-directory property.
1135 ;; We can't really do this here without making dangerous assumptions.
1136 ;;(propertize "Branch: " 'face 'font-lock-type-face)
1137 ;;(propertize "ADD CODE TO PRINT THE BRANCH NAME\n"
1138 ;; 'face 'font-lock-warning-face)
1141 (defun vc-cvs-get-entries (dir)
1142 "Insert the CVS/Entries file from below DIR into the current buffer.
1143 This function ensures that the correct coding system is used for that,
1144 which may not be the one that is used for the files' contents.
1145 CVS/Entries should only be accessed through this function."
1146 (let ((coding-system-for-read (or file-name-coding-system
1147 default-file-name-coding-system
)))
1148 (vc-insert-file (expand-file-name "CVS/Entries" dir
))))
1150 (defun vc-cvs-valid-symbolic-tag-name-p (tag)
1151 "Return non-nil if TAG is a valid symbolic tag name."
1152 ;; According to the CVS manual, a valid symbolic tag must start with
1153 ;; an uppercase or lowercase letter and can contain uppercase and
1154 ;; lowercase letters, digits, `-', and `_'.
1155 (and (string-match "^[a-zA-Z]" tag
)
1156 (not (string-match "[^a-z0-9A-Z-_]" tag
))))
1158 (defun vc-cvs-valid-revision-number-p (tag)
1159 "Return non-nil if TAG is a valid revision number."
1160 (and (string-match "^[0-9]" tag
)
1161 (not (string-match "[^0-9.]" tag
))))
1163 (defun vc-cvs-parse-sticky-tag (match-type match-tag
)
1164 "Parse and return the sticky tag as a string.
1165 `match-data' is protected."
1166 (let ((data (match-data))
1168 (type (cond ((string= match-type
"D") 'date
)
1169 ((string= match-type
"T")
1170 (if (vc-cvs-valid-symbolic-tag-name-p match-tag
)
1177 ;; Sticky Date tag. Convert to a proper date value (`encode-time')
1180 "\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)\\.\\([0-9]+\\)"
1182 (let* ((year-tmp (string-to-number (match-string 1 match-tag
)))
1183 (month (string-to-number (match-string 2 match-tag
)))
1184 (day (string-to-number (match-string 3 match-tag
)))
1185 (hour (string-to-number (match-string 4 match-tag
)))
1186 (min (string-to-number (match-string 5 match-tag
)))
1187 (sec (string-to-number (match-string 6 match-tag
)))
1188 ;; Years 0..68 are 2000..2068.
1189 ;; Years 69..99 are 1969..1999.
1190 (year (+ (cond ((> 69 year-tmp
) 2000)
1191 ((> 100 year-tmp
) 1900)
1194 (setq tag
(encode-time sec min hour day month year
))))
1195 ;; Sticky Tag name or revision number
1196 ((eq type
'symbolic-name
) (setq tag match-tag
))
1197 ((eq type
'revision-number
) (setq tag match-tag
))
1198 ;; Default is no sticky tag at all
1200 (cond ((eq vc-cvs-sticky-tag-display nil
) nil
)
1201 ((eq vc-cvs-sticky-tag-display t
)
1202 (cond ((eq type
'date
) (format-time-string
1203 vc-cvs-sticky-date-format-string
1205 ((eq type
'symbolic-name
) tag
)
1206 ((eq type
'revision-number
) tag
)
1208 ((functionp vc-cvs-sticky-tag-display
)
1209 (funcall vc-cvs-sticky-tag-display tag type
))
1212 (set-match-data data
))))
1214 (defun vc-cvs-parse-entry (file &optional set-state
)
1215 "Parse a line from CVS/Entries.
1216 Compare modification time to that of the FILE, set file properties
1217 accordingly. However, `vc-state' is set only if optional arg SET-STATE
1220 ;; entry for a "locally added" file (not yet committed)
1221 ((looking-at "/[^/]+/0/")
1222 (vc-file-setprop file
'vc-checkout-time
0)
1223 (vc-file-setprop file
'vc-working-revision
"0")
1224 (if set-state
(vc-file-setprop file
'vc-state
'added
)))
1230 ;; timestamp and optional conflict field
1235 "\\(.\\|\\)" ;Sticky tag type (date or tag name, could be empty)
1236 "\\(.*\\)")) ;Sticky tag
1237 (vc-file-setprop file
'vc-working-revision
(match-string 1))
1238 (vc-file-setprop file
'vc-cvs-sticky-tag
1239 (vc-cvs-parse-sticky-tag (match-string 4)
1241 ;; Compare checkout time and modification time.
1242 ;; This is intentionally different from the algorithm that CVS uses
1243 ;; (which is based on textual comparison), because there can be problems
1244 ;; generating a time string that looks exactly like the one from CVS.
1245 (let* ((time (match-string 2))
1246 (mtime (nth 5 (file-attributes file
)))
1247 (parsed-time (progn (require 'parse-time
)
1248 (parse-time-string (concat time
" +0000")))))
1249 (cond ((and (not (string-match "\\+" time
))
1251 ;; Compare just the seconds part of the file time,
1252 ;; since CVS file time stamp resolution is just 1 second.
1253 (let ((ptime (apply 'encode-time parsed-time
)))
1254 (and (eq (car mtime
) (car ptime
))
1255 (eq (cadr mtime
) (cadr ptime
)))))
1256 (vc-file-setprop file
'vc-checkout-time mtime
)
1257 (if set-state
(vc-file-setprop file
'vc-state
'up-to-date
)))
1259 (vc-file-setprop file
'vc-checkout-time
0)
1260 (if set-state
(vc-file-setprop file
'vc-state
'edited
))))))))
1262 ;; Completion of revision names.
1263 ;; Just so I don't feel like I'm duplicating code from pcl-cvs, I'll use
1264 ;; `cvs log' so I can list all the revision numbers rather than only
1267 (defun vc-cvs-revision-table (file)
1268 (let (process-file-side-effects
1269 (default-directory (file-name-directory file
))
1272 (vc-cvs-command t nil file
"log")
1273 (goto-char (point-min))
1274 (when (re-search-forward "^symbolic names:\n" nil t
)
1275 (while (looking-at "^ \\(.*\\): \\(.*\\)")
1276 (push (cons (match-string 1) (match-string 2)) res
)
1278 (while (re-search-forward "^revision \\([0-9.]+\\)" nil t
)
1279 (push (match-string 1) res
))
1282 (defun vc-cvs-revision-completion-table (files)
1283 (letrec ((table (lazy-completion-table
1284 table
(lambda () (vc-cvs-revision-table (car files
))))))
1287 (defun vc-cvs-find-admin-dir (file)
1288 "Return the administrative directory of FILE."
1289 (vc-find-root file
"CVS"))
1291 (defun vc-cvs-ignore (file &optional _directory _remove
)
1292 "Ignore FILE under CVS."
1293 (vc-cvs-append-to-ignore (file-name-directory file
) file
))
1295 (defun vc-cvs-append-to-ignore (dir str
&optional old-dir
)
1296 "In DIR, add STR to the .cvsignore file.
1297 If OLD-DIR is non-nil, then this is a directory that we don't want
1298 to hear about anymore."
1299 (with-current-buffer
1300 (find-file-noselect (expand-file-name ".cvsignore" dir
))
1301 (when (ignore-errors
1302 (and buffer-read-only
1303 (eq 'CVS
(vc-backend buffer-file-name
))
1304 (not (vc-editable-p buffer-file-name
))))
1305 ;; CVSREAD=on special case
1306 (vc-checkout buffer-file-name t
))
1307 (goto-char (point-max))
1308 (unless (bolp) (insert "\n"))
1309 (insert str
(if old-dir
"/\n" "\n"))
1310 ;; FIXME this is a pcvs variable.
1311 (if (bound-and-true-p cvs-sort-ignore-file
)
1312 (sort-lines nil
(point-min) (point-max)))
1317 ;;; vc-cvs.el ends here