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