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