Commit | Line | Data |
---|---|---|
3afbc435 | 1 | ;;; pcvs.el --- a front-end to CVS |
5b467bf4 | 2 | |
38400c2a | 3 | ;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
114f9c96 | 4 | ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
5b467bf4 SM |
5 | |
6 | ;; Author: (The PCL-CVS Trust) pcl-cvs@cyclic.com | |
7 | ;; (Per Cederqvist) ceder@lysator.liu.se | |
8 | ;; (Greg A. Woods) woods@weird.com | |
9 | ;; (Jim Blandy) jimb@cyclic.com | |
10 | ;; (Karl Fogel) kfogel@floss.red-bean.com | |
11 | ;; (Jim Kingdon) kingdon@cyclic.com | |
a7996e05 SM |
12 | ;; (Stefan Monnier) monnier@cs.yale.edu |
13 | ;; (Greg Klanderman) greg@alphatech.com | |
14 | ;; (Jari Aalto+mail.emacs) jari.aalto@poboxes.com | |
3b52037b | 15 | ;; Maintainer: (Stefan Monnier) monnier@gnu.org |
5b467bf4 | 16 | ;; Keywords: CVS, version control, release management |
5b467bf4 SM |
17 | |
18 | ;; This file is part of GNU Emacs. | |
19 | ||
eb3fa2cf | 20 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
5b467bf4 | 21 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
22 | ;; the Free Software Foundation, either version 3 of the License, or |
23 | ;; (at your option) any later version. | |
5b467bf4 SM |
24 | |
25 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
26 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
28 | ;; GNU General Public License for more details. | |
29 | ||
30 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 31 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
5b467bf4 SM |
32 | |
33 | ;;; Commentary: | |
34 | ||
cb3430a1 SM |
35 | ;; PCL-CVS is a front-end to the CVS version control system. For people |
36 | ;; familiar with VC, it is somewhat like VC-dired: it presents the status of | |
37 | ;; all the files in your working area and allows you to commit/update several | |
38 | ;; of them at a time. Compared to VC-dired, it is considerably better and | |
39 | ;; faster (but only for CVS). | |
40 | ||
41 | ;; PCL-CVS was originally written by Per Cederqvist many years ago. This | |
42 | ;; version derives from the XEmacs-21 version, itself based on the 2.0b2 | |
43 | ;; version (last release from Per). It is a thorough rework. | |
44 | ||
45 | ;; Contrary to what you'd expect, PCL-CVS is not a replacement for VC but only | |
46 | ;; for VC-dired. As such, I've tried to make PCL-CVS and VC interoperate | |
47 | ;; seamlessly (I also use VC). | |
48 | ||
49 | ;; To use PCL-CVS just use `M-x cvs-examine RET <dir> RET'. | |
96190aa1 | 50 | ;; There is a TeXinfo manual, which can be helpful to get started. |
cb3430a1 | 51 | |
ee8d23ee SM |
52 | ;;; Bugs: |
53 | ||
76829576 SM |
54 | ;; - Extracting an old version seems not to recognize encoding correctly. |
55 | ;; That's probably because it's done via a process rather than a file. | |
ee8d23ee | 56 | |
5b467bf4 SM |
57 | ;;; Todo: |
58 | ||
cb3430a1 | 59 | ;; ******** FIX THE DOCUMENTATION ********* |
f1180544 | 60 | ;; |
ee8d23ee | 61 | ;; - rework the displaying of error messages. |
316e1d5b SM |
62 | ;; - allow to flush messages only |
63 | ;; - allow to protect files like ChangeLog from flushing | |
64 | ;; - automatically cvs-mode-insert files from find-file-hook | |
d6cc3d17 | 65 | ;; (and don't flush them as long as they are visited) |
316e1d5b SM |
66 | ;; - query the user for cvs-get-marked (for some cmds or if nothing's selected) |
67 | ;; - don't return the first (resp last) FI if the cursor is before | |
68 | ;; (resp after) it. | |
69 | ;; - allow cvs-confirm-removals to force always confirmation. | |
316e1d5b SM |
70 | ;; - cvs-checkout should ask for a revision (with completion). |
71 | ;; - removal confirmation should allow specifying another file name. | |
f1180544 | 72 | ;; |
96190aa1 | 73 | ;; - hide fileinfos without getting rid of them (will require ewok work). |
cb3430a1 SM |
74 | ;; - add toolbar entries |
75 | ;; - marking | |
76 | ;; marking directories should jump to just after the dir. | |
77 | ;; allow (un)marking directories at a time with the mouse. | |
be0add30 SM |
78 | ;; allow cvs-cmd-do to either clear the marks or not. |
79 | ;; add a "marks active" notion, like transient-mark-mode does. | |
cb3430a1 SM |
80 | ;; - liveness indicator |
81 | ;; - indicate in docstring if the cmd understands the `b' prefix(es). | |
82 | ;; - call smerge-mode when opening CONFLICT files. | |
cb3430a1 SM |
83 | ;; - have vc-checkin delegate to cvs-mode-commit when applicable |
84 | ;; - higher-level CVS operations | |
85 | ;; cvs-mode-rename | |
86 | ;; cvs-mode-branch | |
87 | ;; - module-level commands | |
88 | ;; add support for parsing 'modules' file ("cvs co -c") | |
89 | ;; cvs-mode-rcs2log | |
90 | ;; cvs-rdiff | |
91 | ;; cvs-release | |
92 | ;; cvs-import | |
93 | ;; C-u M-x cvs-checkout should ask for a cvsroot | |
94 | ;; cvs-mode-handle-new-vendor-version | |
5b467bf4 SM |
95 | ;; - checks out module, or alternately does update join |
96 | ;; - does "cvs -n tag LAST_VENDOR" to find old files into *cvs* | |
cb3430a1 | 97 | ;; cvs-export |
44946a4c | 98 | ;; (with completion on tag names and hooks to help generate full releases) |
cb3430a1 SM |
99 | ;; - display stickiness information. And current CVS/Tag as well. |
100 | ;; - write 'cvs-mode-admin' to do arbitrary 'cvs admin' commands | |
6dc7d3d5 SM |
101 | ;; Most interesting would be version removal and log message replacement. |
102 | ;; The last one would be neat when called from log-view-mode. | |
cb3430a1 | 103 | ;; - cvs-mode-incorporate |
6dc7d3d5 | 104 | ;; It would merge in the status from one *cvs* buffer into another. |
5b467bf4 SM |
105 | ;; This would be used to populate such a buffer that had been created with |
106 | ;; a `cvs {update,status,checkout} -l'. | |
cb3430a1 SM |
107 | ;; - cvs-mode-(i)diff-other-{file,buffer,cvs-buffer} |
108 | ;; - offer the choice to kill the process when the user kills the cvs buffer. | |
5b467bf4 | 109 | ;; right now, it's killed without further ado. |
cb3430a1 | 110 | ;; - make `cvs-mode-ignore' allow manually entering a pattern. |
5b467bf4 | 111 | ;; to which dir should it apply ? |
cb3430a1 SM |
112 | ;; - cvs-mode-ignore should try to remove duplicate entries. |
113 | ;; - maybe poll/check CVS/Entries files to react to external `cvs' commands ? | |
114 | ;; - some kind of `cvs annotate' support ? | |
5b467bf4 | 115 | ;; but vc-annotate can be used instead. |
44946a4c SM |
116 | ;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine |
117 | ;; maybe also use cvs-update depending on I-don't-know-what. | |
cb3430a1 | 118 | ;; - add message-levels so that we can hide some levels of messages |
5b467bf4 SM |
119 | |
120 | ;;; Code: | |
121 | ||
3db3a13f | 122 | (eval-when-compile (require 'cl)) |
5b467bf4 SM |
123 | (require 'ewoc) ;Ewoc was once cookie |
124 | (require 'pcvs-defs) | |
125 | (require 'pcvs-util) | |
126 | (require 'pcvs-parse) | |
127 | (require 'pcvs-info) | |
128 | ||
129 | \f | |
130 | ;;;; | |
131 | ;;;; global vars | |
132 | ;;;; | |
133 | ||
134 | (defvar cvs-cookies) ;;nil | |
135 | ;;"Handle for the cookie structure that is displayed in the *cvs* buffer.") | |
136 | ;;(make-variable-buffer-local 'cvs-cookies) | |
137 | ||
138 | ;;;; | |
139 | ;;;; Dynamically scoped variables | |
140 | ;;;; | |
141 | ||
142 | (defvar cvs-from-vc nil "Bound to t inside VC advice.") | |
143 | ||
027b73ac | 144 | ;;;; |
5b467bf4 | 145 | ;;;; flags variables |
027b73ac | 146 | ;;;; |
5b467bf4 SM |
147 | |
148 | (defun cvs-defaults (&rest defs) | |
149 | (let ((defs (cvs-first defs cvs-shared-start))) | |
150 | (append defs | |
44946a4c | 151 | (make-list (- cvs-shared-start (length defs)) (car defs)) |
5b467bf4 SM |
152 | cvs-shared-flags))) |
153 | ||
154 | ;; For cvs flags, we need to add "-f" to override the cvsrc settings | |
155 | ;; we also want to evict the annoying -q and -Q options that hide useful | |
156 | ;; information from pcl-cvs. | |
157 | (cvs-flags-define cvs-cvs-flags '(("-f"))) | |
158 | ||
159 | (cvs-flags-define cvs-checkout-flags (cvs-defaults '("-P"))) | |
160 | (cvs-flags-define cvs-status-flags (cvs-defaults '("-v") nil)) | |
161 | (cvs-flags-define cvs-log-flags (cvs-defaults nil)) | |
6dc7d3d5 | 162 | (cvs-flags-define cvs-diff-flags (cvs-defaults '("-u" "-N") '("-c" "-N") '("-u" "-b"))) |
5b467bf4 SM |
163 | (cvs-flags-define cvs-tag-flags (cvs-defaults nil)) |
164 | (cvs-flags-define cvs-add-flags (cvs-defaults nil)) | |
165 | (cvs-flags-define cvs-commit-flags (cvs-defaults nil)) | |
166 | (cvs-flags-define cvs-remove-flags (cvs-defaults nil)) | |
167 | ;;(cvs-flags-define cvs-undo-flags (cvs-defaults nil)) | |
168 | (cvs-flags-define cvs-update-flags (cvs-defaults '("-d" "-P"))) | |
169 | ||
170 | (defun cvs-reread-cvsrc () | |
171 | "Reset the default arguments to those in the `cvs-cvsrc-file'." | |
172 | (interactive) | |
ca0a7168 SM |
173 | (condition-case nil |
174 | (with-temp-buffer | |
175 | (insert-file-contents cvs-cvsrc-file) | |
176 | ;; fetch the values | |
177 | (dolist (cmd '("cvs" "checkout" "status" "log" "diff" "tag" | |
178 | "add" "commit" "remove" "update")) | |
179 | (goto-char (point-min)) | |
843e5edd SM |
180 | (when (re-search-forward |
181 | (concat "^" cmd "\\(\\s-+\\(.*\\)\\)?$") nil t) | |
182 | (let* ((sym (intern (concat "cvs-" cmd "-flags"))) | |
ad4fed11 | 183 | (val (split-string-and-unquote (or (match-string 2) "")))) |
843e5edd | 184 | (cvs-flags-set sym 0 val)))) |
ca0a7168 SM |
185 | ;; ensure that cvs doesn't have -q or -Q |
186 | (cvs-flags-set 'cvs-cvs-flags 0 | |
187 | (cons "-f" | |
188 | (cdr (cvs-partition | |
843e5edd | 189 | (lambda (x) (member x '("-q" "-Q" "-f"))) |
ca0a7168 SM |
190 | (cvs-flags-query 'cvs-cvs-flags |
191 | nil 'noquery)))))) | |
192 | (file-error nil))) | |
5b467bf4 SM |
193 | |
194 | ;; initialize to cvsrc's default values | |
195 | (cvs-reread-cvsrc) | |
196 | ||
197 | \f | |
198 | ;;;; | |
199 | ;;;; Mouse bindings and mode motion | |
200 | ;;;; | |
201 | ||
6a26cf4a SM |
202 | (defvar cvs-minor-current-files) |
203 | ||
5b467bf4 SM |
204 | (defun cvs-menu (e) |
205 | "Popup the CVS menu." | |
206 | (interactive "e") | |
96190aa1 SM |
207 | (let ((cvs-minor-current-files |
208 | (list (ewoc-data (ewoc-locate | |
209 | cvs-cookies (posn-point (event-end e))))))) | |
ee8d23ee | 210 | (popup-menu cvs-menu e))) |
5b467bf4 SM |
211 | |
212 | (defvar cvs-mode-line-process nil | |
213 | "Mode-line control for displaying info on cvs process status.") | |
214 | ||
215 | ||
027b73ac | 216 | ;;;; |
5b467bf4 | 217 | ;;;; Query-Type-Descriptor for Tags |
027b73ac | 218 | ;;;; |
5b467bf4 SM |
219 | |
220 | (autoload 'cvs-status-get-tags "cvs-status") | |
221 | (defun cvs-tags-list () | |
222 | "Return a list of acceptable tags, ready for completions." | |
223 | (assert (cvs-buffer-p)) | |
224 | (let ((marked (cvs-get-marked))) | |
225 | (list* '("BASE") '("HEAD") | |
226 | (when marked | |
227 | (with-temp-buffer | |
62b84d36 | 228 | (process-file cvs-program |
5b467bf4 SM |
229 | nil ;no input |
230 | t ;output to current-buffer | |
231 | nil ;don't update display while running | |
232 | "status" | |
233 | "-v" | |
2231c2bc | 234 | (cvs-fileinfo->full-name (car marked))) |
5b467bf4 SM |
235 | (goto-char (point-min)) |
236 | (let ((tags (cvs-status-get-tags))) | |
237 | (when (listp tags) tags))))))) | |
238 | ||
239 | (defvar cvs-tag-history nil) | |
240 | (defconst cvs-qtypedesc-tag | |
241 | (cvs-qtypedesc-create 'identity 'identity 'cvs-tags-list 'cvs-tag-history)) | |
242 | ||
027b73ac | 243 | ;;;; |
5b467bf4 | 244 | |
906cbe45 | 245 | (defun cvs-mode! (&optional -cvs-mode!-fun) |
5b467bf4 SM |
246 | "Switch to the *cvs* buffer. |
247 | If -CVS-MODE!-FUN is provided, it is executed *cvs* being the current buffer | |
248 | and with its window selected. Else, the *cvs* buffer is simply selected. | |
5b467bf4 SM |
249 | -CVS-MODE!-FUN is called interactively if applicable and else with no argument." |
250 | (let* ((-cvs-mode!-buf (current-buffer)) | |
251 | (cvsbuf (cond ((cvs-buffer-p) (current-buffer)) | |
252 | ((and cvs-buffer (cvs-buffer-p cvs-buffer)) cvs-buffer) | |
3afbc435 | 253 | (t (error "can't find the *cvs* buffer")))) |
5b467bf4 SM |
254 | (-cvs-mode!-wrapper cvs-minor-wrap-function) |
255 | (-cvs-mode!-cont (lambda () | |
256 | (save-current-buffer | |
257 | (if (commandp -cvs-mode!-fun) | |
258 | (call-interactively -cvs-mode!-fun) | |
259 | (funcall -cvs-mode!-fun)))))) | |
260 | (if (not -cvs-mode!-fun) (set-buffer cvsbuf) | |
261 | (let ((cvs-mode!-buf (current-buffer)) | |
262 | (cvs-mode!-owin (selected-window)) | |
263 | (cvs-mode!-nwin (get-buffer-window cvsbuf 'visible))) | |
264 | (unwind-protect | |
265 | (progn | |
266 | (set-buffer cvsbuf) | |
267 | (when cvs-mode!-nwin (select-window cvs-mode!-nwin)) | |
268 | (if -cvs-mode!-wrapper | |
269 | (funcall -cvs-mode!-wrapper -cvs-mode!-buf -cvs-mode!-cont) | |
270 | (funcall -cvs-mode!-cont))) | |
271 | (set-buffer cvs-mode!-buf) | |
272 | (when (and cvs-mode!-nwin (eq cvs-mode!-nwin (selected-window))) | |
273 | ;; the selected window has not been changed by FUN | |
274 | (select-window cvs-mode!-owin))))))) | |
275 | ||
027b73ac | 276 | ;;;; |
5b467bf4 | 277 | ;;;; Prefixes |
027b73ac | 278 | ;;;; |
5b467bf4 SM |
279 | |
280 | (defvar cvs-branches (list cvs-vendor-branch "HEAD" "HEAD")) | |
281 | (cvs-prefix-define cvs-branch-prefix | |
282 | "Current selected branch." | |
283 | "version" | |
284 | (cons cvs-vendor-branch cvs-branches) | |
285 | cvs-qtypedesc-tag) | |
286 | ||
287 | (defun cvs-set-branch-prefix (arg) | |
288 | "Set the branch prefix to take action at the next command. | |
289 | See `cvs-prefix-set' for a further the description of the behavior. | |
290 | \\[universal-argument] 1 selects the vendor branch | |
291 | and \\[universal-argument] 2 selects the HEAD." | |
292 | (interactive "P") | |
293 | (cvs-mode!) | |
294 | (cvs-prefix-set 'cvs-branch-prefix arg)) | |
295 | ||
296 | (defun cvs-add-branch-prefix (flags &optional arg) | |
297 | "Add branch selection argument if the branch prefix was set. | |
298 | The argument is added (or not) to the list of FLAGS and is constructed | |
299 | by appending the branch to ARG which defaults to \"-r\"." | |
300 | (let ((branch (cvs-prefix-get 'cvs-branch-prefix))) | |
301 | ;; deactivate the secondary prefix, even if not used. | |
302 | (cvs-prefix-get 'cvs-secondary-branch-prefix) | |
303 | (if branch (cons (concat (or arg "-r") branch) flags) flags))) | |
304 | ||
305 | (cvs-prefix-define cvs-secondary-branch-prefix | |
306 | "Current secondary selected branch." | |
307 | "version" | |
308 | (cons cvs-vendor-branch cvs-branches) | |
309 | cvs-qtypedesc-tag) | |
310 | ||
311 | (defun cvs-set-secondary-branch-prefix (arg) | |
312 | "Set the branch prefix to take action at the next command. | |
313 | See `cvs-prefix-set' for a further the description of the behavior. | |
314 | \\[universal-argument] 1 selects the vendor branch | |
315 | and \\[universal-argument] 2 selects the HEAD." | |
316 | (interactive "P") | |
317 | (cvs-mode!) | |
318 | (cvs-prefix-set 'cvs-secondary-branch-prefix arg)) | |
319 | ||
320 | (defun cvs-add-secondary-branch-prefix (flags &optional arg) | |
321 | "Add branch selection argument if the secondary branch prefix was set. | |
322 | The argument is added (or not) to the list of FLAGS and is constructed | |
323 | by appending the branch to ARG which defaults to \"-r\". | |
324 | Since the `cvs-secondary-branch-prefix' is only active if the primary | |
325 | prefix is active, it is important to read the secondary prefix before | |
326 | the primay since reading the primary can deactivate it." | |
327 | (let ((branch (and (cvs-prefix-get 'cvs-branch-prefix 'read-only) | |
328 | (cvs-prefix-get 'cvs-secondary-branch-prefix)))) | |
329 | (if branch (cons (concat (or arg "-r") branch) flags) flags))) | |
330 | ||
027b73ac | 331 | ;;;; |
5b467bf4 | 332 | |
316e1d5b SM |
333 | (define-minor-mode cvs-minor-mode |
334 | "This mode is used for buffers related to a main *cvs* buffer. | |
5b467bf4 | 335 | All the `cvs-mode' buffer operations are simply rebound under |
316e1d5b | 336 | the \\[cvs-mode-map] prefix." |
00821115 MR |
337 | nil " CVS" |
338 | :group 'pcl-cvs) | |
5b467bf4 SM |
339 | (put 'cvs-minor-mode 'permanent-local t) |
340 | ||
341 | ||
342 | (defvar cvs-temp-buffers nil) | |
343 | (defun cvs-temp-buffer (&optional cmd normal nosetup) | |
344 | "Create a temporary buffer to run CMD in. | |
345 | If CMD is a string, use it to lookup `cvs-buffer-name-alist' to find | |
346 | the buffer name to be used and its `major-mode'. | |
347 | ||
348 | The selected window will not be changed. The new buffer will not maintain undo | |
349 | information and will be read-only unless NORMAL is non-nil. It will be emptied | |
350 | \(unless NOSETUP is non-nil\) and its `default-directory' will be inherited | |
351 | from the current buffer." | |
352 | (let* ((cvs-buf (current-buffer)) | |
353 | (info (cdr (assoc cmd cvs-buffer-name-alist))) | |
dedffa6a GM |
354 | (name (eval (nth 0 info))) |
355 | (mode (nth 1 info)) | |
5b467bf4 SM |
356 | (dir default-directory) |
357 | (buf (cond | |
358 | (name (cvs-get-buffer-create name)) | |
8f53f317 | 359 | ((and (bufferp cvs-temp-buffer) (buffer-live-p cvs-temp-buffer)) |
5b467bf4 SM |
360 | cvs-temp-buffer) |
361 | (t | |
362 | (set (make-local-variable 'cvs-temp-buffer) | |
363 | (cvs-get-buffer-create | |
364 | (eval cvs-temp-buffer-name) 'noreuse)))))) | |
027b73ac | 365 | |
5b467bf4 SM |
366 | ;; handle the potential pre-existing process |
367 | (let ((proc (get-buffer-process buf))) | |
368 | (when (and (not normal) (processp proc) | |
369 | (memq (process-status proc) '(run stop))) | |
8a769de6 SM |
370 | (if cmd |
371 | ;; When CMD is specified, the buffer is normally shown to the | |
372 | ;; user, so interrupting the process is not harmful. | |
373 | ;; Use `delete-process' rather than `kill-process' otherwise | |
374 | ;; the pending output of the process will still get inserted | |
375 | ;; after we erase the buffer. | |
376 | (delete-process proc) | |
377 | (error "Can not run two cvs processes simultaneously")))) | |
5b467bf4 SM |
378 | |
379 | (if (not name) (kill-local-variable 'other-window-scroll-buffer) | |
380 | ;; Strangely, if no window is created, `display-buffer' ends up | |
381 | ;; doing a `switch-to-buffer' which does a `set-buffer', hence | |
382 | ;; the need for `save-excursion'. | |
383 | (unless nosetup (save-excursion (display-buffer buf))) | |
384 | ;; FIXME: this doesn't do the right thing if the user later on | |
385 | ;; does a `find-file-other-window' and `scroll-other-window' | |
386 | (set (make-local-variable 'other-window-scroll-buffer) buf)) | |
387 | ||
388 | (add-to-list 'cvs-temp-buffers buf) | |
389 | ||
390 | (with-current-buffer buf | |
391 | (setq buffer-read-only nil) | |
392 | (setq default-directory dir) | |
405b8717 SM |
393 | (unless nosetup |
394 | ;; Disable undo before calling erase-buffer since it may generate | |
395 | ;; a very large and unwanted undo record. | |
396 | (buffer-disable-undo) | |
397 | (erase-buffer)) | |
5b467bf4 SM |
398 | (set (make-local-variable 'cvs-buffer) cvs-buf) |
399 | ;;(cvs-minor-mode 1) | |
400 | (let ((lbd list-buffers-directory)) | |
405b8717 | 401 | (if (fboundp mode) (funcall mode) (fundamental-mode)) |
11ee8d90 | 402 | (when lbd (setq list-buffers-directory lbd))) |
5b467bf4 SM |
403 | (cvs-minor-mode 1) |
404 | ;;(set (make-local-variable 'cvs-buffer) cvs-buf) | |
405b8717 SM |
405 | (if normal |
406 | (buffer-enable-undo) | |
5b467bf4 SM |
407 | (setq buffer-read-only t) |
408 | (buffer-disable-undo)) | |
409 | buf))) | |
410 | ||
411 | (defun cvs-mode-kill-buffers () | |
412 | "Kill all the \"temporary\" buffers created by the *cvs* buffer." | |
413 | (interactive) | |
414 | (dolist (buf cvs-temp-buffers) (ignore-errors (kill-buffer buf)))) | |
415 | ||
416 | (defun cvs-make-cvs-buffer (dir &optional new) | |
417 | "Create the *cvs* buffer for directory DIR. | |
418 | If non-nil, NEW means to create a new buffer no matter what." | |
419 | ;; the real cvs-buffer creation | |
420 | (setq dir (cvs-expand-dir-name dir)) | |
421 | (let* ((buffer-name (eval cvs-buffer-name)) | |
422 | (buffer | |
423 | (or (and (not new) | |
424 | (eq cvs-reuse-cvs-buffer 'current) | |
425 | (cvs-buffer-p) ;reuse the current buffer if possible | |
426 | (current-buffer)) | |
427 | ;; look for another cvs buffer visiting the same directory | |
428 | (save-excursion | |
429 | (unless new | |
430 | (dolist (buffer (cons (current-buffer) (buffer-list))) | |
431 | (set-buffer buffer) | |
432 | (and (cvs-buffer-p) | |
433 | (case cvs-reuse-cvs-buffer | |
434 | (always t) | |
435 | (subdir | |
436 | (or (cvs-string-prefix-p default-directory dir) | |
437 | (cvs-string-prefix-p dir default-directory))) | |
438 | (samedir (string= default-directory dir))) | |
439 | (return buffer))))) | |
440 | ;; we really have to create a new buffer: | |
441 | ;; we temporarily bind cwd to "" to prevent | |
442 | ;; create-file-buffer from using directory info | |
443 | ;; unless it is explicitly in the cvs-buffer-name. | |
444 | (cvs-get-buffer-create buffer-name new)))) | |
445 | (with-current-buffer buffer | |
446 | (or | |
447 | (and (string= dir default-directory) (cvs-buffer-p) | |
448 | ;; just a refresh | |
449 | (ignore-errors | |
450 | (cvs-cleanup-collection cvs-cookies nil nil t) | |
451 | (current-buffer))) | |
452 | ;; setup from scratch | |
453 | (progn | |
454 | (setq default-directory dir) | |
455 | (setq buffer-read-only nil) | |
456 | (erase-buffer) | |
94d79fb4 SM |
457 | (insert "Repository : " (directory-file-name (cvs-get-cvsroot)) |
458 | "\nModule : " (cvs-get-module) | |
459 | "\nWorking dir: " (abbreviate-file-name dir) | |
460 | (if (not (file-readable-p "CVS/Tag")) "\n" | |
461 | (let ((tag (cvs-file-to-string "CVS/Tag"))) | |
462 | (cond | |
463 | ((string-match "\\`T" tag) | |
464 | (concat "\nTag : " (substring tag 1))) | |
465 | ((string-match "\\`D" tag) | |
466 | (concat "\nDate : " (substring tag 1))) | |
8a769de6 SM |
467 | ("\n")))) |
468 | "\n") | |
5b467bf4 SM |
469 | (setq buffer-read-only t) |
470 | (cvs-mode) | |
471 | (set (make-local-variable 'list-buffers-directory) buffer-name) | |
472 | ;;(set (make-local-variable 'cvs-temp-buffer) (cvs-temp-buffer)) | |
1b04f30a | 473 | (let ((cookies (ewoc-create 'cvs-fileinfo-pp "\n\n" "\n" t))) |
5b467bf4 | 474 | (set (make-local-variable 'cvs-cookies) cookies) |
5b467bf4 SM |
475 | (add-hook 'kill-buffer-hook |
476 | (lambda () | |
477 | (ignore-errors (kill-buffer cvs-temp-buffer))) | |
478 | nil t) | |
479 | ;;(set-buffer buf) | |
480 | buffer)))))) | |
481 | ||
482 | (defun* cvs-cmd-do (cmd dir flags fis new | |
483 | &key cvsargs noexist dont-change-disc noshow) | |
484 | (let* ((dir (file-name-as-directory | |
485 | (abbreviate-file-name (expand-file-name dir)))) | |
486 | (cvsbuf (cvs-make-cvs-buffer dir new))) | |
487 | ;; Check that dir is under CVS control. | |
488 | (unless (file-directory-p dir) | |
6dc7d3d5 | 489 | (error "%s is not a directory" dir)) |
883e7198 SM |
490 | (unless (or noexist (file-directory-p (expand-file-name "CVS" dir)) |
491 | (file-expand-wildcards (expand-file-name "*/CVS" dir))) | |
6dc7d3d5 | 492 | (error "%s does not contain CVS controlled files" dir)) |
5b467bf4 SM |
493 | |
494 | (set-buffer cvsbuf) | |
495 | (cvs-mode-run cmd flags fis | |
496 | :cvsargs cvsargs :dont-change-disc dont-change-disc) | |
497 | ||
498 | (if noshow cvsbuf | |
499 | (let ((pop-up-windows nil)) (pop-to-buffer cvsbuf))))) | |
500 | ;; (funcall (if (and (boundp 'pop-up-frames) pop-up-frames) | |
501 | ;; 'pop-to-buffer 'switch-to-buffer) | |
502 | ;; cvsbuf)))) | |
503 | ||
5b467bf4 SM |
504 | (defun cvs-run-process (args fis postprocess &optional single-dir) |
505 | (assert (cvs-buffer-p cvs-buffer)) | |
506 | (save-current-buffer | |
507 | (let ((procbuf (current-buffer)) | |
508 | (cvsbuf cvs-buffer) | |
509 | (single-dir (or single-dir (eq cvs-execute-single-dir t)))) | |
027b73ac | 510 | |
5b467bf4 SM |
511 | (set-buffer procbuf) |
512 | (goto-char (point-max)) | |
513 | (unless (bolp) (let ((inhibit-read-only t)) (insert "\n"))) | |
514 | ;; find the set of files we'll process in this round | |
515 | (let* ((dir+files+rest | |
516 | (if (or (null fis) (not single-dir)) | |
517 | ;; not single-dir mode: just process the whole thing | |
2231c2bc | 518 | (list "" (mapcar 'cvs-fileinfo->full-name fis) nil) |
5b467bf4 SM |
519 | ;; single-dir mode: extract the same-dir-elements |
520 | (let ((dir (cvs-fileinfo->dir (car fis)))) | |
521 | ;; output the concerned dir so the parser can translate paths | |
522 | (let ((inhibit-read-only t)) | |
523 | (insert "pcl-cvs: descending directory " dir "\n")) | |
524 | ;; loop to find the same-dir-elems | |
525 | (do* ((files () (cons (cvs-fileinfo->file fi) files)) | |
526 | (fis fis (cdr fis)) | |
527 | (fi (car fis) (car fis))) | |
528 | ((not (and fis (string= dir (cvs-fileinfo->dir fi)))) | |
529 | (list dir files fis)))))) | |
dedffa6a GM |
530 | (dir (nth 0 dir+files+rest)) |
531 | (files (nth 1 dir+files+rest)) | |
532 | (rest (nth 2 dir+files+rest))) | |
027b73ac | 533 | |
5b467bf4 SM |
534 | (add-hook 'kill-buffer-hook |
535 | (lambda () | |
536 | (let ((proc (get-buffer-process (current-buffer)))) | |
537 | (when (processp proc) | |
538 | (set-process-filter proc nil) | |
8f53f317 SM |
539 | ;; Abort postprocessing but leave the sentinel so it |
540 | ;; will update the list of running procs. | |
541 | (process-put proc 'cvs-postprocess nil) | |
542 | (interrupt-process proc)))) | |
5b467bf4 SM |
543 | nil t) |
544 | ||
545 | ;; create the new process and setup the procbuffer correspondingly | |
8f53f317 SM |
546 | (let* ((msg (cvs-header-msg args fis)) |
547 | (args (append (cvs-flags-query 'cvs-cvs-flags nil 'noquery) | |
5b467bf4 SM |
548 | (if cvs-cvsroot (list "-d" cvs-cvsroot)) |
549 | args | |
550 | files)) | |
6b2e4334 SM |
551 | ;; If process-connection-type is nil and the repository |
552 | ;; is accessed via SSH, a bad interaction between libc, | |
553 | ;; CVS and SSH can lead to garbled output. | |
8f53f317 | 554 | ;; It might be a glibc-specific problem (but it can also happens |
1854d6e2 | 555 | ;; under Mac OS X, it seems). |
8f53f317 SM |
556 | ;; It seems that using a pty can help circumvent the problem, |
557 | ;; but at the cost of screwing up when the process thinks it | |
558 | ;; can ask for user input (such as password or host-key | |
559 | ;; confirmation). A better workaround is to set CVS_RSH to | |
560 | ;; an appropriate script, or to use a later version of CVS. | |
561 | (process-connection-type nil) ; Use a pipe, not a pty. | |
5b467bf4 SM |
562 | (process |
563 | ;; the process will be run in the selected dir | |
564 | (let ((default-directory (cvs-expand-dir-name dir))) | |
62b84d36 | 565 | (apply 'start-file-process "cvs" procbuf cvs-program args)))) |
8f53f317 SM |
566 | ;; setup the process. |
567 | (process-put process 'cvs-buffer cvs-buffer) | |
568 | (with-current-buffer cvs-buffer (cvs-update-header msg 'add)) | |
569 | (process-put process 'cvs-header msg) | |
570 | (process-put | |
571 | process 'cvs-postprocess | |
572 | (if (null rest) | |
573 | ;; this is the last invocation | |
574 | postprocess | |
575 | ;; else, we have to register ourselves to be rerun on the rest | |
576 | `(cvs-run-process ',args ',rest ',postprocess ',single-dir))) | |
5b467bf4 SM |
577 | (set-process-sentinel process 'cvs-sentinel) |
578 | (set-process-filter process 'cvs-update-filter) | |
579 | (set-marker (process-mark process) (point-max)) | |
580 | (ignore-errors (process-send-eof process)) ;close its stdin to avoid hangs | |
027b73ac | 581 | |
5b467bf4 SM |
582 | ;; now finish setting up the cvs-buffer |
583 | (set-buffer cvsbuf) | |
584 | (setq cvs-mode-line-process (symbol-name (process-status process))) | |
585 | (force-mode-line-update))))) | |
586 | ||
587 | ;; The following line is said to improve display updates on some | |
588 | ;; emacsen. It shouldn't be needed, but it does no harm. | |
589 | (sit-for 0)) | |
590 | ||
31982e1f | 591 | (defun cvs-header-msg (args fis) |
5b467bf4 | 592 | (let* ((lastarg nil) |
5b467bf4 SM |
593 | (args (mapcar (lambda (arg) |
594 | (cond | |
6b2e4334 | 595 | ;; filter out the largish commit message |
5b467bf4 SM |
596 | ((and (eq lastarg nil) (string= arg "commit")) |
597 | (setq lastarg 'commit) arg) | |
598 | ((and (eq lastarg 'commit) (string= arg "-m")) | |
599 | (setq lastarg '-m) arg) | |
600 | ((eq lastarg '-m) | |
601 | (setq lastarg 'done) "<log message>") | |
6b2e4334 SM |
602 | ;; filter out the largish `admin -mrev:msg' message |
603 | ((and (eq lastarg nil) (string= arg "admin")) | |
604 | (setq lastarg 'admin) arg) | |
605 | ((and (eq lastarg 'admin) | |
606 | (string-match "\\`-m[^:]*:" arg)) | |
607 | (setq lastarg 'done) | |
608 | (concat (match-string 0 arg) "<log message>")) | |
609 | ;; Keep the rest as is. | |
5b467bf4 | 610 | (t arg))) |
31982e1f SM |
611 | args))) |
612 | (concat cvs-program " " | |
ad4fed11 | 613 | (combine-and-quote-strings |
31982e1f SM |
614 | (append (cvs-flags-query 'cvs-cvs-flags nil 'noquery) |
615 | (if cvs-cvsroot (list "-d" cvs-cvsroot)) | |
616 | args | |
2231c2bc | 617 | (mapcar 'cvs-fileinfo->full-name fis)))))) |
31982e1f SM |
618 | |
619 | (defun cvs-update-header (cmd add) | |
620 | (let* ((hf (ewoc-get-hf cvs-cookies)) | |
621 | (str (car hf)) | |
622 | (done "") | |
623 | (tin (ewoc-nth cvs-cookies 0))) | |
31982e1f SM |
624 | ;; look for the first *real* fileinfo (to determine emptyness) |
625 | (while | |
626 | (and tin | |
627 | (memq (cvs-fileinfo->type (ewoc-data tin)) | |
628 | '(MESSAGE DIRCHANGE))) | |
629 | (setq tin (ewoc-next cvs-cookies tin))) | |
630 | (if add | |
04e408d9 SM |
631 | (progn |
632 | ;; Remove the default empty line, if applicable. | |
633 | (if (not (string-match "." str)) (setq str "\n")) | |
634 | (setq str (concat "-- Running " cmd " ...\n" str))) | |
31982e1f | 635 | (if (not (string-match |
8b5f251b SM |
636 | ;; FIXME: If `cmd' is large, this will bump into the |
637 | ;; compiled-regexp size limit. We could drop the "^" anchor | |
638 | ;; and use search-forward to circumvent the problem. | |
31982e1f SM |
639 | (concat "^-- Running " (regexp-quote cmd) " \\.\\.\\.\n") str)) |
640 | (error "Internal PCL-CVS error while removing message") | |
641 | (setq str (replace-match "" t t str)) | |
04e408d9 SM |
642 | ;; Re-add the default empty line, if applicable. |
643 | (if (not (string-match "." str)) (setq str "\n\n")) | |
644 | (setq done (concat "-- last cmd: " cmd " --\n")))) | |
31982e1f SM |
645 | ;; set the new header and footer |
646 | (ewoc-set-hf cvs-cookies | |
647 | str (concat "\n--------------------- " | |
648 | (if tin "End" "Empty") | |
649 | " ---------------------\n" | |
650 | done)))) | |
5b467bf4 SM |
651 | |
652 | ||
5b467bf4 SM |
653 | (defun cvs-sentinel (proc msg) |
654 | "Sentinel for the cvs update process. | |
655 | This is responsible for parsing the output from the cvs update when | |
656 | it is finished." | |
657 | (when (memq (process-status proc) '(signal exit)) | |
5f0e7257 | 658 | (let ((cvs-postproc (process-get proc 'cvs-postprocess)) |
7a34e7b1 SM |
659 | (cvs-buf (process-get proc 'cvs-buffer)) |
660 | (procbuf (process-buffer proc))) | |
661 | (unless (buffer-live-p cvs-buf) (setq cvs-buf nil)) | |
662 | (unless (buffer-live-p procbuf) (setq procbuf nil)) | |
8f53f317 SM |
663 | ;; Since the buffer and mode line will show that the |
664 | ;; process is dead, we can delete it now. Otherwise it | |
665 | ;; will stay around until M-x list-processes. | |
666 | (process-put proc 'postprocess nil) | |
667 | (delete-process proc) | |
668 | ;; Don't do anything if the main buffer doesn't exist any more. | |
7a34e7b1 | 669 | (when cvs-buf |
8f53f317 SM |
670 | (with-current-buffer cvs-buf |
671 | (cvs-update-header (process-get proc 'cvs-header) nil) | |
672 | (setq cvs-mode-line-process (symbol-name (process-status proc))) | |
673 | (force-mode-line-update) | |
674 | (when cvs-postproc | |
7a34e7b1 | 675 | (if (null procbuf) |
8f53f317 SM |
676 | ;;(set-process-buffer proc nil) |
677 | (error "cvs' process buffer was killed") | |
7a34e7b1 SM |
678 | (with-current-buffer procbuf |
679 | ;; Do the postprocessing like parsing and such. | |
680 | (save-excursion (eval cvs-postproc))))))) | |
681 | ;; Check whether something is left. | |
682 | (when (and procbuf (not (get-buffer-process procbuf))) | |
683 | (with-current-buffer procbuf | |
684 | ;; IIRC, we enable undo again once the process is finished | |
685 | ;; for cases where the output was inserted in *vc-diff* or | |
686 | ;; in a file-like buffer. --Stef | |
687 | (buffer-enable-undo) | |
688 | (with-current-buffer (or cvs-buf (current-buffer)) | |
689 | (message "CVS process has completed in %s" | |
690 | (buffer-name)))))))) | |
5b467bf4 | 691 | |
a399e814 SM |
692 | (defun cvs-parse-process (dcd &optional subdir old-fis) |
693 | "Parse the output of a cvs process. | |
694 | DCD is the `dont-change-disc' flag to use when parsing that output. | |
695 | SUBDIR is the subdirectory (if any) where this command was run. | |
696 | OLD-FIS is the list of fileinfos on which the cvs command was applied and | |
697 | which should be considered up-to-date if they are missing from the output." | |
3b52037b SM |
698 | (when (eq system-type 'darwin) |
699 | ;; Fixup the ^D^H^H inserted at beginning of buffer sometimes on MacOSX | |
700 | ;; because of the call to `process-send-eof'. | |
701 | (save-excursion | |
702 | (goto-char (point-min)) | |
703 | (while (re-search-forward "^\\^D\b+" nil t) | |
704 | (let ((inhibit-read-only t)) | |
705 | (delete-region (match-beginning 0) (match-end 0)))))) | |
498ecdde SM |
706 | (let* ((fileinfos (cvs-parse-buffer 'cvs-parse-table dcd subdir)) |
707 | last) | |
708 | (with-current-buffer cvs-buffer | |
709 | ;; Expand OLD-FIS to actual files. | |
710 | (let ((fis nil)) | |
711 | (dolist (fi old-fis) | |
712 | (setq fis (if (eq (cvs-fileinfo->type fi) 'DIRCHANGE) | |
713 | (nconc (ewoc-collect cvs-cookies 'cvs-dir-member-p | |
714 | (cvs-fileinfo->dir fi)) | |
715 | fis) | |
716 | (cons fi fis)))) | |
717 | (setq old-fis fis)) | |
718 | ;; Drop OLD-FIS which were already up-to-date. | |
719 | (let ((fis nil)) | |
720 | (dolist (fi old-fis) | |
721 | (unless (eq (cvs-fileinfo->type fi) 'UP-TO-DATE) (push fi fis))) | |
722 | (setq old-fis fis)) | |
723 | ;; Add the new fileinfos to the ewoc. | |
724 | (dolist (fi fileinfos) | |
725 | (setq last (cvs-addto-collection cvs-cookies fi last)) | |
726 | ;; This FI was in the output, so remove it from OLD-FIS. | |
727 | (setq old-fis (delq (ewoc-data last) old-fis))) | |
728 | ;; Process the "silent output" (i.e. absence means up-to-date). | |
a399e814 | 729 | (dolist (fi old-fis) |
498ecdde SM |
730 | (setf (cvs-fileinfo->type fi) 'UP-TO-DATE) |
731 | (setq last (cvs-addto-collection cvs-cookies fi last))) | |
732 | (setq fileinfos (nconc old-fis fileinfos)) | |
733 | ;; Clean up the ewoc as requested by the user. | |
734 | (cvs-cleanup-collection cvs-cookies | |
735 | (eq cvs-auto-remove-handled t) | |
736 | cvs-auto-remove-directories | |
737 | nil) | |
738 | ;; Revert buffers if necessary. | |
739 | (when (and cvs-auto-revert (not dcd) (not cvs-from-vc)) | |
740 | (cvs-revert-if-needed fileinfos))))) | |
5b467bf4 SM |
741 | |
742 | (defmacro defun-cvs-mode (fun args docstring interact &rest body) | |
743 | "Define a function to be used in a *cvs* buffer. | |
744 | This will look for a *cvs* buffer and execute BODY in it. | |
745 | Since the interactive arguments might need to be queried after | |
746 | switching to the *cvs* buffer, the generic code is rather ugly, | |
747 | but luckily we can often use simpler alternatives. | |
748 | ||
749 | FUN can be either a symbol (i.e. STYLE is nil) or a cons (FUN . STYLE). | |
750 | ARGS and DOCSTRING are the normal argument list. | |
751 | INTERACT is the interactive specification or nil for non-commands. | |
752 | ||
753 | STYLE can be either SIMPLE, NOARGS or DOUBLE. It's an error for it | |
754 | to have any other value, unless other details of the function make it | |
755 | clear what alternative to use. | |
756 | - SIMPLE will get all the interactive arguments from the original buffer. | |
757 | - NOARGS will get all the arguments from the *cvs* buffer and will | |
758 | always behave as if called interactively. | |
759 | - DOUBLE is the generic case." | |
a96a1d43 JPW |
760 | (declare (debug (&define sexp lambda-list stringp ("interactive" interactive) def-body)) |
761 | (doc-string 3)) | |
5b467bf4 SM |
762 | (let ((style (cvs-cdr fun)) |
763 | (fun (cvs-car fun))) | |
764 | (cond | |
765 | ;; a trivial interaction, no need to move it | |
766 | ((or (eq style 'SIMPLE) | |
dedffa6a GM |
767 | (null (nth 1 interact)) |
768 | (stringp (nth 1 interact))) | |
5b467bf4 SM |
769 | `(defun ,fun ,args ,docstring ,interact |
770 | (cvs-mode! (lambda () ,@body)))) | |
771 | ||
772 | ;; fun is only called interactively: move all the args to the inner fun | |
773 | ((eq style 'NOARGS) | |
774 | `(defun ,fun () ,docstring (interactive) | |
775 | (cvs-mode! (lambda ,args ,interact ,@body)))) | |
776 | ||
777 | ;; bad case | |
778 | ((eq style 'DOUBLE) | |
779 | (string-match ".*" docstring) | |
780 | (let ((line1 (match-string 0 docstring)) | |
5b467bf4 SM |
781 | (fun-1 (intern (concat (symbol-name fun) "-1")))) |
782 | `(progn | |
783 | (defun ,fun-1 ,args | |
784 | ,(concat docstring "\nThis function only works within a *cvs* buffer. | |
785 | For interactive use, use `" (symbol-name fun) "' instead.") | |
786 | ,interact | |
787 | ,@body) | |
bd9fa00e | 788 | (put ',fun-1 'definition-name ',fun) |
5b467bf4 SM |
789 | (defun ,fun () |
790 | ,(concat line1 "\nWrapper function that switches to a *cvs* buffer | |
791 | before calling the real function `" (symbol-name fun-1) "'.\n") | |
792 | (interactive) | |
793 | (cvs-mode! ',fun-1))))) | |
794 | ||
91ba1953 | 795 | (t (error "Unknown style %s in `defun-cvs-mode'" style))))) |
5b467bf4 SM |
796 | |
797 | (defun-cvs-mode cvs-mode-kill-process () | |
798 | "Kill the temporary buffer and associated process." | |
799 | (interactive) | |
8f53f317 | 800 | (when (and (bufferp cvs-temp-buffer) (buffer-live-p cvs-temp-buffer)) |
5b467bf4 SM |
801 | (let ((proc (get-buffer-process cvs-temp-buffer))) |
802 | (when proc (delete-process proc))))) | |
803 | ||
be0add30 SM |
804 | ;; |
805 | ;; Maintaining the collection in the face of updates | |
806 | ;; | |
5b467bf4 SM |
807 | |
808 | (defun cvs-addto-collection (c fi &optional tin) | |
3c7fafc7 | 809 | "Add FI to C and return FI's corresponding tin. |
5b467bf4 SM |
810 | FI is inserted in its proper place or maybe even merged with a preexisting |
811 | fileinfo if applicable. | |
812 | TIN specifies an optional starting point." | |
813 | (unless tin (setq tin (ewoc-nth c 0))) | |
814 | (while (and tin (cvs-fileinfo< fi (ewoc-data tin))) | |
815 | (setq tin (ewoc-prev c tin))) | |
3c7fafc7 | 816 | (if (null tin) (ewoc-enter-first c fi) ;empty collection |
5b467bf4 SM |
817 | (assert (not (cvs-fileinfo< fi (ewoc-data tin)))) |
818 | (let ((next-tin (ewoc-next c tin))) | |
819 | (while (not (or (null next-tin) | |
820 | (cvs-fileinfo< fi (ewoc-data next-tin)))) | |
821 | (setq tin next-tin next-tin (ewoc-next c next-tin))) | |
be0add30 SM |
822 | (if (or (cvs-fileinfo< (ewoc-data tin) fi) |
823 | (eq (cvs-fileinfo->type fi) 'MESSAGE)) | |
5b467bf4 SM |
824 | ;; tin < fi < next-tin |
825 | (ewoc-enter-after c tin fi) | |
826 | ;; fi == tin | |
827 | (cvs-fileinfo-update (ewoc-data tin) fi) | |
3c7fafc7 | 828 | (ewoc-invalidate c tin) |
498ecdde SM |
829 | ;; Move cursor back to where it belongs. |
830 | (when (bolp) (cvs-move-to-goal-column)) | |
3c7fafc7 | 831 | tin)))) |
5b467bf4 | 832 | |
6dc7d3d5 SM |
833 | (defcustom cvs-cleanup-functions nil |
834 | "Functions to tweak the cleanup process. | |
835 | The functions are called with a single argument (a FILEINFO) and should | |
836 | return a non-nil value if that fileinfo should be removed." | |
837 | :group 'pcl-cvs | |
838 | :type '(hook :options (cvs-cleanup-removed))) | |
839 | ||
840 | (defun cvs-cleanup-removed (fi) | |
841 | "Non-nil if FI has been cvs-removed but still exists. | |
842 | This is intended for use on `cvs-cleanup-functions' when you have cvs-removed | |
843 | automatically generated files (which should hence not be under CVS control) | |
844 | but can't commit the removal because the repository's owner doesn't understand | |
845 | the problem." | |
846 | (and (or (eq (cvs-fileinfo->type fi) 'REMOVED) | |
847 | (and (eq (cvs-fileinfo->type fi) 'CONFLICT) | |
848 | (eq (cvs-fileinfo->subtype fi) 'REMOVED))) | |
2231c2bc | 849 | (file-exists-p (cvs-fileinfo->full-name fi)))) |
6dc7d3d5 | 850 | |
5b467bf4 SM |
851 | ;; called at the following times: |
852 | ;; - postparse ((eq cvs-auto-remove-handled t) cvs-auto-remove-directories nil) | |
853 | ;; - pre-run ((eq cvs-auto-remove-handled 'delayed) nil t) | |
854 | ;; - remove-handled (t (or cvs-auto-remove-directories 'handled) t) | |
855 | ;; - cvs-cmd-do (nil nil t) | |
856 | ;; - post-ignore (nil nil nil) | |
857 | ;; - acknowledge (nil nil nil) | |
858 | ;; - remove (nil nil nil) | |
859 | (defun cvs-cleanup-collection (c rm-handled rm-dirs rm-msgs) | |
860 | "Remove undesired entries. | |
861 | C is the collection | |
862 | RM-HANDLED if non-nil means remove handled entries. | |
863 | RM-DIRS behaves like `cvs-auto-remove-directories'. | |
864 | RM-MSGS if non-nil means remove messages." | |
865 | (let (last-fi first-dir (rerun t)) | |
866 | (while rerun | |
867 | (setq rerun nil) | |
868 | (setq first-dir t) | |
869 | (setq last-fi (cvs-create-fileinfo 'DEAD "../" "" "")) ;place-holder | |
870 | (ewoc-filter | |
871 | c (lambda (fi) | |
872 | (let* ((type (cvs-fileinfo->type fi)) | |
873 | (subtype (cvs-fileinfo->subtype fi)) | |
874 | (keep | |
875 | (case type | |
876 | ;; remove temp messages and keep the others | |
b15b5618 | 877 | (MESSAGE (not (or rm-msgs (eq subtype 'TEMP)))) |
5b467bf4 SM |
878 | ;; remove entries |
879 | (DEAD nil) | |
880 | ;; handled also? | |
881 | (UP-TO-DATE (not rm-handled)) | |
882 | ;; keep the rest | |
6dc7d3d5 SM |
883 | (t (not (run-hook-with-args-until-success |
884 | 'cvs-cleanup-functions fi)))))) | |
027b73ac | 885 | |
5b467bf4 SM |
886 | ;; mark dirs for removal |
887 | (when (and keep rm-dirs | |
888 | (eq (cvs-fileinfo->type last-fi) 'DIRCHANGE) | |
889 | (not (when first-dir (setq first-dir nil) t)) | |
890 | (or (eq rm-dirs 'all) | |
891 | (not (cvs-string-prefix-p | |
892 | (cvs-fileinfo->dir last-fi) | |
893 | (cvs-fileinfo->dir fi))) | |
894 | (and (eq type 'DIRCHANGE) (eq rm-dirs 'empty)) | |
895 | (eq subtype 'FOOTER))) | |
896 | (setf (cvs-fileinfo->type last-fi) 'DEAD) | |
897 | (setq rerun t)) | |
b15b5618 SM |
898 | (when keep (setq last-fi fi))))) |
899 | ;; remove empty last dir | |
900 | (when (and rm-dirs | |
901 | (not first-dir) | |
902 | (eq (cvs-fileinfo->type last-fi) 'DIRCHANGE)) | |
903 | (setf (cvs-fileinfo->type last-fi) 'DEAD) | |
904 | (setq rerun t))))) | |
5b467bf4 SM |
905 | |
906 | (defun cvs-get-cvsroot () | |
907 | "Gets the CVSROOT for DIR." | |
908 | (let ((cvs-cvsroot-file (expand-file-name "Root" "CVS"))) | |
909 | (or (cvs-file-to-string cvs-cvsroot-file t) | |
910 | cvs-cvsroot | |
911 | (getenv "CVSROOT") | |
912 | "?????"))) | |
913 | ||
914 | (defun cvs-get-module () | |
915 | "Return the current CVS module. | |
916 | This usually doesn't really work but is a handy initval in a prompt." | |
917 | (let* ((repfile (expand-file-name "Repository" "CVS")) | |
918 | (rep (cvs-file-to-string repfile t))) | |
919 | (cond | |
920 | ((null rep) "") | |
921 | ((not (file-name-absolute-p rep)) rep) | |
922 | (t | |
923 | (let* ((root (cvs-get-cvsroot)) | |
924 | (str (concat (file-name-as-directory (or root "/")) " || " rep))) | |
925 | (if (and root (string-match "\\(.*\\) || \\1\\(.*\\)\\'" str)) | |
926 | (match-string 2 str) | |
927 | (file-name-nondirectory rep))))))) | |
928 | ||
929 | ||
930 | \f | |
931 | ;;;; | |
932 | ;;;; running a "cvs checkout". | |
933 | ;;;; | |
934 | ||
935 | ;;;###autoload | |
59bb9410 | 936 | (defun cvs-checkout (modules dir flags &optional root) |
5b467bf4 SM |
937 | "Run a 'cvs checkout MODULES' in DIR. |
938 | Feed the output to a *cvs* buffer, display it in the current window, | |
939 | and run `cvs-mode' on it. | |
940 | ||
941 | With a prefix argument, prompt for cvs FLAGS to use." | |
942 | (interactive | |
59bb9410 SM |
943 | (let ((root (cvs-get-cvsroot))) |
944 | (if (or (null root) current-prefix-arg) | |
945 | (setq root (read-string "CVS Root: "))) | |
ad4fed11 RS |
946 | (list (split-string-and-unquote |
947 | (read-string "Module(s): " (cvs-get-module))) | |
59bb9410 SM |
948 | (read-directory-name "CVS Checkout Directory: " |
949 | nil default-directory nil) | |
950 | (cvs-add-branch-prefix | |
951 | (cvs-flags-query 'cvs-checkout-flags "cvs checkout flags")) | |
952 | root))) | |
5b467bf4 SM |
953 | (when (eq flags t) |
954 | (setf flags (cvs-flags-query 'cvs-checkout-flags nil 'noquery))) | |
59bb9410 SM |
955 | (let ((cvs-cvsroot root)) |
956 | (cvs-cmd-do "checkout" (or dir default-directory) | |
957 | (append flags modules) nil 'new | |
958 | :noexist t))) | |
5b467bf4 | 959 | |
38400c2a SM |
960 | (defun-cvs-mode (cvs-mode-checkout . NOARGS) (dir) |
961 | "Run cvs checkout against the current branch. | |
962 | The files are stored to DIR." | |
e248903c | 963 | (interactive |
38400c2a | 964 | (let* ((branch (cvs-prefix-get 'cvs-branch-prefix)) |
e248903c | 965 | (prompt (format "CVS Checkout Directory for `%s%s': " |
38400c2a SM |
966 | (cvs-get-module) |
967 | (if branch (format " (branch: %s)" branch) | |
968 | "")))) | |
969 | (list (read-directory-name prompt nil default-directory nil)))) | |
ad4fed11 | 970 | (let ((modules (split-string-and-unquote (cvs-get-module))) |
38400c2a SM |
971 | (flags (cvs-add-branch-prefix |
972 | (cvs-flags-query 'cvs-checkout-flags "cvs checkout flags"))) | |
973 | (cvs-cvsroot (cvs-get-cvsroot))) | |
974 | (cvs-checkout modules dir flags))) | |
5b467bf4 | 975 | \f |
027b73ac | 976 | ;;;; |
5b467bf4 | 977 | ;;;; The code for running a "cvs update" and friends in various ways. |
027b73ac | 978 | ;;;; |
5b467bf4 SM |
979 | |
980 | (defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE) | |
981 | (&optional ignore-auto noconfirm) | |
f3d73dc9 | 982 | "Rerun `cvs-examine' on the current directory with the default flags." |
5b467bf4 SM |
983 | (interactive) |
984 | (cvs-examine default-directory t)) | |
985 | ||
f29897bb RS |
986 | (defun cvs-query-directory (prompt) |
987 | "Read directory name, prompting with PROMPT. | |
988 | If in a *cvs* buffer, don't prompt unless a prefix argument is given." | |
5b467bf4 | 989 | (if (and (cvs-buffer-p) |
f29897bb | 990 | (not current-prefix-arg)) |
5b467bf4 | 991 | default-directory |
f29897bb | 992 | (read-directory-name prompt nil default-directory nil))) |
5b467bf4 | 993 | |
6dc7d3d5 SM |
994 | ;;;###autoload |
995 | (defun cvs-quickdir (dir &optional flags noshow) | |
996 | "Open a *cvs* buffer on DIR without running cvs. | |
997 | With a prefix argument, prompt for a directory to use. | |
998 | A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]), | |
999 | prevents reuse of an existing *cvs* buffer. | |
1000 | Optional argument NOSHOW if non-nil means not to display the buffer. | |
1001 | FLAGS is ignored." | |
1002 | (interactive (list (cvs-query-directory "CVS quickdir (directory): "))) | |
1003 | ;; FIXME: code duplication with cvs-cmd-do and cvs-parse-process | |
1004 | (let* ((dir (file-name-as-directory | |
1005 | (abbreviate-file-name (expand-file-name dir)))) | |
1006 | (new (> (prefix-numeric-value current-prefix-arg) 8)) | |
1007 | (cvsbuf (cvs-make-cvs-buffer dir new)) | |
1008 | last) | |
1009 | ;; Check that dir is under CVS control. | |
1010 | (unless (file-directory-p dir) | |
1011 | (error "%s is not a directory" dir)) | |
1012 | (unless (file-directory-p (expand-file-name "CVS" dir)) | |
1013 | (error "%s does not contain CVS controlled files" dir)) | |
1014 | (set-buffer cvsbuf) | |
1015 | (dolist (fi (cvs-fileinfo-from-entries "")) | |
1016 | (setq last (cvs-addto-collection cvs-cookies fi last))) | |
1017 | (cvs-cleanup-collection cvs-cookies | |
1018 | (eq cvs-auto-remove-handled t) | |
1019 | cvs-auto-remove-directories | |
1020 | nil) | |
1021 | (if noshow cvsbuf | |
1022 | (let ((pop-up-windows nil)) (pop-to-buffer cvsbuf))))) | |
5b467bf4 SM |
1023 | |
1024 | ;;;###autoload | |
1025 | (defun cvs-examine (directory flags &optional noshow) | |
1026 | "Run a `cvs -n update' in the specified DIRECTORY. | |
1027 | That is, check what needs to be done, but don't change the disc. | |
1028 | Feed the output to a *cvs* buffer and run `cvs-mode' on it. | |
1029 | With a prefix argument, prompt for a directory and cvs FLAGS to use. | |
1030 | A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]), | |
1031 | prevents reuse of an existing *cvs* buffer. | |
1032 | Optional argument NOSHOW if non-nil means not to display the buffer." | |
1033 | (interactive (list (cvs-query-directory "CVS Examine (directory): ") | |
1034 | (cvs-flags-query 'cvs-update-flags "cvs -n update flags"))) | |
1035 | (when (eq flags t) | |
1036 | (setf flags (cvs-flags-query 'cvs-update-flags nil 'noquery))) | |
160181b8 | 1037 | (when find-file-visit-truename (setq directory (file-truename directory))) |
5b467bf4 SM |
1038 | (cvs-cmd-do "update" directory flags nil |
1039 | (> (prefix-numeric-value current-prefix-arg) 8) | |
1040 | :cvsargs '("-n") | |
1041 | :noshow noshow | |
1042 | :dont-change-disc t)) | |
1043 | ||
1044 | ||
1045 | ;;;###autoload | |
1046 | (defun cvs-update (directory flags) | |
1047 | "Run a `cvs update' in the current working DIRECTORY. | |
1048 | Feed the output to a *cvs* buffer and run `cvs-mode' on it. | |
3dcdb054 | 1049 | With a \\[universal-argument] prefix argument, prompt for a directory to use. |
5b467bf4 | 1050 | A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]), |
3dcdb054 SM |
1051 | prevents reuse of an existing *cvs* buffer. |
1052 | The prefix is also passed to `cvs-flags-query' to select the FLAGS | |
1053 | passed to cvs." | |
5b467bf4 SM |
1054 | (interactive (list (cvs-query-directory "CVS Update (directory): ") |
1055 | (cvs-flags-query 'cvs-update-flags "cvs update flags"))) | |
1056 | (when (eq flags t) | |
1057 | (setf flags (cvs-flags-query 'cvs-update-flags nil 'noquery))) | |
1058 | (cvs-cmd-do "update" directory flags nil | |
1059 | (> (prefix-numeric-value current-prefix-arg) 8))) | |
1060 | ||
1061 | ||
1062 | ;;;###autoload | |
1063 | (defun cvs-status (directory flags &optional noshow) | |
1064 | "Run a `cvs status' in the current working DIRECTORY. | |
1065 | Feed the output to a *cvs* buffer and run `cvs-mode' on it. | |
1066 | With a prefix argument, prompt for a directory and cvs FLAGS to use. | |
1067 | A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]), | |
1068 | prevents reuse of an existing *cvs* buffer. | |
1069 | Optional argument NOSHOW if non-nil means not to display the buffer." | |
1070 | (interactive (list (cvs-query-directory "CVS Status (directory): ") | |
1071 | (cvs-flags-query 'cvs-status-flags "cvs status flags"))) | |
1072 | (when (eq flags t) | |
1073 | (setf flags (cvs-flags-query 'cvs-status-flags nil 'noquery))) | |
1074 | (cvs-cmd-do "status" directory flags nil | |
1075 | (> (prefix-numeric-value current-prefix-arg) 8) | |
1076 | :noshow noshow :dont-change-disc t)) | |
1077 | ||
5b467bf4 SM |
1078 | (defun cvs-update-filter (proc string) |
1079 | "Filter function for pcl-cvs. | |
1080 | This function gets the output that CVS sends to stdout. It inserts | |
1081 | the STRING into (process-buffer PROC) but it also checks if CVS is waiting | |
1082 | for a lock file. If so, it inserts a message cookie in the *cvs* buffer." | |
1083 | (save-match-data | |
1084 | (with-current-buffer (process-buffer proc) | |
1085 | (let ((inhibit-read-only t)) | |
1086 | (save-excursion | |
1087 | ;; Insert the text, moving the process-marker. | |
1088 | (goto-char (process-mark proc)) | |
1089 | (insert string) | |
1090 | (set-marker (process-mark proc) (point)) | |
1091 | ;; FIXME: Delete any old lock message | |
1092 | ;;(if (tin-nth cookies 1) | |
1093 | ;; (tin-delete cookies | |
1094 | ;; (tin-nth cookies 1))) | |
1095 | ;; Check if CVS is waiting for a lock. | |
316e1d5b | 1096 | (beginning-of-line 0) ;Move to beginning of last complete line. |
5b467bf4 SM |
1097 | (when (looking-at "^[ a-z]+: \\(.*waiting for .*lock in \\(.*\\)\\)$") |
1098 | (let ((msg (match-string 1)) | |
1099 | (lock (match-string 2))) | |
1100 | (with-current-buffer cvs-buffer | |
1101 | (set (make-local-variable 'cvs-lock-file) lock) | |
1102 | ;; display the lock situation in the *cvs* buffer: | |
1103 | (ewoc-enter-last | |
1104 | cvs-cookies | |
1105 | (cvs-create-fileinfo | |
1106 | 'MESSAGE "" " " | |
1107 | (concat msg | |
be0add30 SM |
1108 | (when (file-exists-p lock) |
1109 | (substitute-command-keys | |
1110 | "\n\t(type \\[cvs-mode-delete-lock] to delete it)"))) | |
5b467bf4 SM |
1111 | :subtype 'TEMP)) |
1112 | (pop-to-buffer (current-buffer)) | |
1113 | (goto-char (point-max)) | |
1114 | (beep))))))))) | |
1115 | ||
1116 | \f | |
1117 | ;;;; | |
1118 | ;;;; The cvs-mode and its associated commands. | |
1119 | ;;;; | |
1120 | ||
1121 | (cvs-prefix-define cvs-force-command "" "" '("/F") cvs-qtypedesc-string1) | |
1122 | (defun-cvs-mode cvs-mode-force-command (arg) | |
1123 | "Force the next cvs command to operate on all the selected files. | |
1124 | By default, cvs commands only operate on files on which the command | |
1125 | \"makes sense\". This overrides the safety feature on the next cvs command. | |
1126 | It actually behaves as a toggle. If prefixed by \\[universal-argument] \\[universal-argument], | |
1127 | the override will persist until the next toggle." | |
1128 | (interactive "P") | |
1129 | (cvs-prefix-set 'cvs-force-command arg)) | |
1130 | ||
5b467bf4 | 1131 | (put 'cvs-mode 'mode-class 'special) |
94d79fb4 | 1132 | (define-derived-mode cvs-mode nil "CVS" |
5b467bf4 | 1133 | "Mode used for PCL-CVS, a frontend to CVS. |
cb3430a1 | 1134 | Full documentation is in the Texinfo file." |
5b467bf4 SM |
1135 | (setq mode-line-process |
1136 | '("" cvs-force-command cvs-ignore-marks-modif | |
1137 | ":" (cvs-branch-prefix | |
1138 | ("" cvs-branch-prefix (cvs-secondary-branch-prefix | |
1139 | ("->" cvs-secondary-branch-prefix)))) | |
1140 | " " cvs-mode-line-process)) | |
94d79fb4 | 1141 | (if buffer-file-name |
e248903c | 1142 | (error "Use M-x cvs-quickdir to get a *cvs* buffer")) |
6b2e4334 | 1143 | (buffer-disable-undo) |
5b467bf4 SM |
1144 | ;;(set (make-local-variable 'goal-column) cvs-cursor-column) |
1145 | (set (make-local-variable 'revert-buffer-function) 'cvs-mode-revert-buffer) | |
cb3430a1 | 1146 | (setq truncate-lines t) |
5b467bf4 SM |
1147 | (cvs-prefix-make-local 'cvs-branch-prefix) |
1148 | (cvs-prefix-make-local 'cvs-secondary-branch-prefix) | |
1149 | (cvs-prefix-make-local 'cvs-force-command) | |
1150 | (cvs-prefix-make-local 'cvs-ignore-marks-modif) | |
1151 | (make-local-variable 'cvs-mode-line-process) | |
1152 | (make-local-variable 'cvs-temp-buffers)) | |
1153 | ||
1154 | ||
1155 | (defun cvs-buffer-p (&optional buffer) | |
1156 | "Return whether the (by default current) BUFFER is a `cvs-mode' buffer." | |
1157 | (save-excursion | |
1158 | (if buffer (set-buffer buffer)) | |
1159 | (and (eq major-mode 'cvs-mode)))) | |
1160 | ||
1161 | (defun cvs-buffer-check () | |
1162 | "Check that the current buffer follows cvs-buffer's conventions." | |
1163 | (let ((buf (current-buffer)) | |
1164 | (check 'none)) | |
1165 | (or (and (setq check 'collection) | |
1166 | (eq (ewoc-buffer cvs-cookies) buf) | |
1167 | (setq check 'cvs-temp-buffer) | |
1168 | (or (null cvs-temp-buffer) | |
8f53f317 | 1169 | (null (buffer-live-p cvs-temp-buffer)) |
5b467bf4 SM |
1170 | (and (eq (with-current-buffer cvs-temp-buffer cvs-buffer) buf) |
1171 | (equal (with-current-buffer cvs-temp-buffer | |
1172 | default-directory) | |
1173 | default-directory))) | |
1174 | t) | |
1175 | (error "Inconsistent %s in buffer %s" check (buffer-name buf))))) | |
1176 | ||
1177 | ||
ee8d23ee | 1178 | (defun cvs-mode-quit () |
5b467bf4 SM |
1179 | "Quit PCL-CVS, killing the *cvs* buffer." |
1180 | (interactive) | |
1181 | (and (y-or-n-p "Quit pcl-cvs? ") (kill-buffer (current-buffer)))) | |
1182 | ||
1183 | ;; Give help.... | |
1184 | ||
1185 | (defun cvs-help () | |
1186 | "Display help for various PCL-CVS commands." | |
1187 | (interactive) | |
1188 | (if (eq last-command 'cvs-help) | |
ca98cd37 | 1189 | (describe-function 'cvs-mode) ; would need minor-mode for log-edit-mode |
8a26c165 | 1190 | (message "%s" |
5b467bf4 SM |
1191 | (substitute-command-keys |
1192 | "`\\[cvs-help]':help `\\[cvs-mode-add]':add `\\[cvs-mode-commit]':commit \ | |
1193 | `\\[cvs-mode-diff-map]':diff* `\\[cvs-mode-log]':log \ | |
1194 | `\\[cvs-mode-remove]':remove `\\[cvs-mode-status]':status \ | |
1195 | `\\[cvs-mode-undo]':undo")))) | |
1196 | ||
5b467bf4 SM |
1197 | ;; Move around in the buffer |
1198 | ||
498ecdde SM |
1199 | (defun cvs-move-to-goal-column () |
1200 | (let* ((eol (line-end-position)) | |
1201 | (fpos (next-single-property-change (point) 'cvs-goal-column nil eol))) | |
1202 | (when (< fpos eol) | |
1203 | (goto-char fpos)))) | |
1204 | ||
5b467bf4 SM |
1205 | (defun-cvs-mode cvs-mode-previous-line (arg) |
1206 | "Go to the previous line. | |
1207 | If a prefix argument is given, move by that many lines." | |
1208 | (interactive "p") | |
6efa25a1 | 1209 | (ewoc-goto-prev cvs-cookies arg) |
498ecdde | 1210 | (cvs-move-to-goal-column)) |
5b467bf4 SM |
1211 | |
1212 | (defun-cvs-mode cvs-mode-next-line (arg) | |
1213 | "Go to the next line. | |
1214 | If a prefix argument is given, move by that many lines." | |
1215 | (interactive "p") | |
6efa25a1 | 1216 | (ewoc-goto-next cvs-cookies arg) |
498ecdde | 1217 | (cvs-move-to-goal-column)) |
5b467bf4 | 1218 | |
027b73ac | 1219 | ;;;; |
5b467bf4 | 1220 | ;;;; Mark handling |
027b73ac | 1221 | ;;;; |
5b467bf4 SM |
1222 | |
1223 | (defun-cvs-mode cvs-mode-mark (&optional arg) | |
1224 | "Mark the fileinfo on the current line. | |
1225 | If the fileinfo is a directory, all the contents of that directory are | |
1226 | marked instead. A directory can never be marked." | |
1227 | (interactive) | |
44946a4c | 1228 | (let* ((tin (ewoc-locate cvs-cookies)) |
5b467bf4 SM |
1229 | (fi (ewoc-data tin))) |
1230 | (if (eq (cvs-fileinfo->type fi) 'DIRCHANGE) | |
1231 | ;; it's a directory: let's mark all files inside | |
1232 | (ewoc-map | |
1233 | (lambda (f dir) | |
1234 | (when (cvs-dir-member-p f dir) | |
1235 | (setf (cvs-fileinfo->marked f) | |
1236 | (not (if (eq arg 'toggle) (cvs-fileinfo->marked f) arg))) | |
316e1d5b | 1237 | t)) ;Tell cookie to redisplay this cookie. |
5b467bf4 SM |
1238 | cvs-cookies |
1239 | (cvs-fileinfo->dir fi)) | |
1240 | ;; not a directory: just do the obvious | |
1241 | (setf (cvs-fileinfo->marked fi) | |
1242 | (not (if (eq arg 'toggle) (cvs-fileinfo->marked fi) arg))) | |
1243 | (ewoc-invalidate cvs-cookies tin) | |
1244 | (cvs-mode-next-line 1)))) | |
1245 | ||
6dfa5acf SM |
1246 | (defalias 'cvs-mouse-toggle-mark 'cvs-mode-toggle-mark) |
1247 | (defun cvs-mode-toggle-mark (e) | |
1248 | "Toggle the mark of the entry at point." | |
1249 | (interactive (list last-input-event)) | |
44946a4c | 1250 | (save-excursion |
6dfa5acf | 1251 | (posn-set-point (event-end e)) |
44946a4c | 1252 | (cvs-mode-mark 'toggle))) |
5b467bf4 SM |
1253 | |
1254 | (defun-cvs-mode cvs-mode-unmark () | |
1255 | "Unmark the fileinfo on the current line." | |
1256 | (interactive) | |
1257 | (cvs-mode-mark t)) | |
1258 | ||
1259 | (defun-cvs-mode cvs-mode-mark-all-files () | |
1260 | "Mark all files." | |
1261 | (interactive) | |
1262 | (ewoc-map (lambda (cookie) | |
316e1d5b SM |
1263 | (unless (eq (cvs-fileinfo->type cookie) 'DIRCHANGE) |
1264 | (setf (cvs-fileinfo->marked cookie) t))) | |
1265 | cvs-cookies)) | |
5b467bf4 | 1266 | |
be0add30 SM |
1267 | (defun-cvs-mode (cvs-mode-mark-on-state . SIMPLE) (state) |
1268 | "Mark all files in state STATE." | |
1269 | (interactive | |
1270 | (list | |
1271 | (let ((default | |
1272 | (condition-case nil | |
1273 | (downcase | |
1274 | (symbol-name | |
1275 | (cvs-fileinfo->type | |
1276 | (cvs-mode-marked nil nil :read-only t :one t :noquery t)))) | |
1277 | (error nil)))) | |
1278 | (intern | |
1279 | (upcase | |
1280 | (completing-read | |
1281 | (concat | |
1282 | "Mark files in state" (if default (concat " [" default "]")) ": ") | |
1283 | (mapcar (lambda (x) | |
1284 | (list (downcase (symbol-name (car x))))) | |
1285 | cvs-states) | |
1286 | nil t nil nil default)))))) | |
1287 | (ewoc-map (lambda (fi) | |
1288 | (when (eq (cvs-fileinfo->type fi) state) | |
1289 | (setf (cvs-fileinfo->marked fi) t))) | |
1290 | cvs-cookies)) | |
1291 | ||
5b467bf4 SM |
1292 | (defun-cvs-mode cvs-mode-mark-matching-files (regex) |
1293 | "Mark all files matching REGEX." | |
1294 | (interactive "sMark files matching: ") | |
1295 | (ewoc-map (lambda (cookie) | |
316e1d5b SM |
1296 | (when (and (not (eq (cvs-fileinfo->type cookie) 'DIRCHANGE)) |
1297 | (string-match regex (cvs-fileinfo->file cookie))) | |
1298 | (setf (cvs-fileinfo->marked cookie) t))) | |
1299 | cvs-cookies)) | |
5b467bf4 SM |
1300 | |
1301 | (defun-cvs-mode cvs-mode-unmark-all-files () | |
1302 | "Unmark all files. | |
1303 | Directories are also unmarked, but that doesn't matter, since | |
1304 | they should always be unmarked." | |
1305 | (interactive) | |
1306 | (ewoc-map (lambda (cookie) | |
316e1d5b SM |
1307 | (setf (cvs-fileinfo->marked cookie) nil) |
1308 | t) | |
1309 | cvs-cookies)) | |
5b467bf4 SM |
1310 | |
1311 | (defun-cvs-mode cvs-mode-unmark-up () | |
1312 | "Unmark the file on the previous line." | |
1313 | (interactive) | |
44946a4c | 1314 | (let ((tin (ewoc-goto-prev cvs-cookies 1))) |
5b467bf4 SM |
1315 | (when tin |
1316 | (setf (cvs-fileinfo->marked (ewoc-data tin)) nil) | |
d3ffebbc TTN |
1317 | (ewoc-invalidate cvs-cookies tin))) |
1318 | (cvs-move-to-goal-column)) | |
5b467bf4 SM |
1319 | |
1320 | (defconst cvs-ignore-marks-alternatives | |
1321 | '(("toggle-marks" . "/TM") | |
1322 | ("force-marks" . "/FM") | |
1323 | ("ignore-marks" . "/IM"))) | |
1324 | ||
1325 | (cvs-prefix-define cvs-ignore-marks-modif | |
1326 | "Prefix to decide whether to ignore marks or not." | |
1327 | "active" | |
1328 | (mapcar 'cdr cvs-ignore-marks-alternatives) | |
1329 | (cvs-qtypedesc-create | |
1330 | (lambda (str) (cdr (assoc str cvs-ignore-marks-alternatives))) | |
b47e5116 | 1331 | (lambda (obj) (car (rassoc obj cvs-ignore-marks-alternatives))) |
5b467bf4 SM |
1332 | (lambda () cvs-ignore-marks-alternatives) |
1333 | nil t)) | |
027b73ac | 1334 | |
5b467bf4 SM |
1335 | (defun-cvs-mode cvs-mode-toggle-marks (arg) |
1336 | "Toggle whether the next CVS command uses marks. | |
1337 | See `cvs-prefix-set' for further description of the behavior. | |
1338 | \\[universal-argument] 1 selects `force-marks', | |
1339 | \\[universal-argument] 2 selects `ignore-marks', | |
1340 | \\[universal-argument] 3 selects `toggle-marks'." | |
1341 | (interactive "P") | |
1342 | (cvs-prefix-set 'cvs-ignore-marks-modif arg)) | |
027b73ac | 1343 | |
5b467bf4 SM |
1344 | (defun cvs-ignore-marks-p (cmd &optional read-only) |
1345 | (let ((default (if (member cmd cvs-invert-ignore-marks) | |
1346 | (not cvs-default-ignore-marks) | |
1347 | cvs-default-ignore-marks)) | |
1348 | (modif (cvs-prefix-get 'cvs-ignore-marks-modif read-only))) | |
1349 | (cond | |
1350 | ((equal modif "/IM") t) | |
1351 | ((equal modif "/TM") (not default)) | |
1352 | ((equal modif "/FM") nil) | |
1353 | (t default)))) | |
1354 | ||
1355 | (defun cvs-mode-mark-get-modif (cmd) | |
1356 | (if (cvs-ignore-marks-p cmd 'read-only) "/IM" "/FM")) | |
1357 | ||
5b467bf4 SM |
1358 | (defun cvs-get-marked (&optional ignore-marks ignore-contents) |
1359 | "Return a list of all selected fileinfos. | |
1360 | If there are any marked tins, and IGNORE-MARKS is nil, return them. | |
1361 | Otherwise, if the cursor selects a directory, and IGNORE-CONTENTS is | |
1362 | nil, return all files in it, else return just the directory. | |
1363 | Otherwise return (a list containing) the file the cursor points to, or | |
f009f3bc | 1364 | an empty list if it doesn't point to a file at all." |
5b467bf4 | 1365 | (let ((fis nil)) |
96190aa1 SM |
1366 | (dolist (fi (if (and (boundp 'cvs-minor-current-files) |
1367 | (consp cvs-minor-current-files)) | |
5b467bf4 SM |
1368 | (mapcar |
1369 | (lambda (f) | |
96190aa1 SM |
1370 | (if (cvs-fileinfo-p f) f |
1371 | (let ((f (file-relative-name f))) | |
1372 | (if (file-directory-p f) | |
1373 | (cvs-create-fileinfo | |
1374 | 'DIRCHANGE (file-name-as-directory f) "." "") | |
1375 | (let ((dir (file-name-directory f)) | |
1376 | (file (file-name-nondirectory f))) | |
1377 | (cvs-create-fileinfo | |
1378 | 'UNKNOWN (or dir "") file "")))))) | |
5b467bf4 SM |
1379 | cvs-minor-current-files) |
1380 | (or (and (not ignore-marks) | |
316e1d5b | 1381 | (ewoc-collect cvs-cookies 'cvs-fileinfo->marked)) |
44946a4c | 1382 | (list (ewoc-data (ewoc-locate cvs-cookies)))))) |
027b73ac | 1383 | |
5b467bf4 SM |
1384 | (if (or ignore-contents (not (eq (cvs-fileinfo->type fi) 'DIRCHANGE))) |
1385 | (push fi fis) | |
1386 | ;; If a directory is selected, return members, if any. | |
1387 | (setq fis | |
802cf66c SM |
1388 | (append (ewoc-collect |
1389 | cvs-cookies 'cvs-dir-member-p (cvs-fileinfo->dir fi)) | |
5b467bf4 SM |
1390 | fis)))) |
1391 | (nreverse fis))) | |
1392 | ||
802cf66c | 1393 | (defun* cvs-mode-marked (filter &optional cmd |
316e1d5b | 1394 | &key read-only one file noquery) |
5b467bf4 SM |
1395 | "Get the list of marked FIS. |
1396 | CMD is used to determine whether to use the marks or not. | |
1397 | Only files for which FILTER is applicable are returned. | |
1398 | If READ-ONLY is non-nil, the current toggling is left intact. | |
1399 | If ONE is non-nil, marks are ignored and a single FI is returned. | |
1400 | If FILE is non-nil, directory entries won't be selected." | |
802cf66c | 1401 | (unless cmd (setq cmd (symbol-name filter))) |
5b467bf4 | 1402 | (let* ((fis (cvs-get-marked (or one (cvs-ignore-marks-p cmd read-only)) |
316e1d5b SM |
1403 | (and (not file) |
1404 | (cvs-applicable-p 'DIRCHANGE filter)))) | |
5b467bf4 SM |
1405 | (force (cvs-prefix-get 'cvs-force-command)) |
1406 | (fis (car (cvs-partition | |
1407 | (lambda (fi) (cvs-applicable-p fi (and (not force) filter))) | |
1408 | fis)))) | |
316e1d5b SM |
1409 | (when (and (or (null fis) (and one (cdr fis))) (not noquery)) |
1410 | (message (if (null fis) | |
1411 | "`%s' is not applicable to any of the selected files." | |
1412 | "`%s' is only applicable to a single file.") cmd) | |
802cf66c | 1413 | (sit-for 1) |
316e1d5b SM |
1414 | (setq fis (list (cvs-insert-file |
1415 | (read-file-name (format "File to %s: " cmd)))))) | |
1416 | (if one (car fis) fis))) | |
5b467bf4 SM |
1417 | |
1418 | (defun cvs-enabledp (filter) | |
1419 | "Determine whether FILTER applies to at least one of the selected files." | |
598dd5ff | 1420 | (ignore-errors (cvs-mode-marked filter nil :read-only t :noquery t))) |
5b467bf4 SM |
1421 | |
1422 | (defun cvs-mode-files (&rest -cvs-mode-files-args) | |
1423 | (cvs-mode! | |
1424 | (lambda () | |
2231c2bc | 1425 | (mapcar 'cvs-fileinfo->full-name |
5b467bf4 SM |
1426 | (apply 'cvs-mode-marked -cvs-mode-files-args))))) |
1427 | ||
be0add30 SM |
1428 | ;; |
1429 | ;; Interface between Log-Edit and PCL-CVS | |
1430 | ;; | |
5b467bf4 SM |
1431 | |
1432 | (defun cvs-mode-commit-setup () | |
1433 | "Run `cvs-mode-commit' with setup." | |
1434 | (interactive) | |
1435 | (cvs-mode-commit 'force)) | |
1436 | ||
98a68b08 SM |
1437 | (defcustom cvs-mode-commit-hook nil |
1438 | "Hook run after setting up the commit buffer." | |
1439 | :type 'hook | |
00821115 MR |
1440 | :options '(cvs-mode-diff) |
1441 | :group 'pcl-cvs) | |
98a68b08 | 1442 | |
5b467bf4 SM |
1443 | (defun cvs-mode-commit (setup) |
1444 | "Check in all marked files, or the current file. | |
1445 | The user will be asked for a log message in a buffer. | |
1446 | The buffer's mode and name is determined by the \"message\" setting | |
1447 | of `cvs-buffer-name-alist'. | |
ca98cd37 | 1448 | The POSTPROC specified there (typically `log-edit') is then called, |
5b467bf4 SM |
1449 | passing it the SETUP argument." |
1450 | (interactive "P") | |
1451 | ;; It seems that the save-excursion that happens if I use the better | |
1452 | ;; form of `(cvs-mode! (lambda ...))' screws up a couple things which | |
ca98cd37 | 1453 | ;; end up being rather annoying (like log-edit-mode's message being |
5b467bf4 SM |
1454 | ;; displayed in the wrong minibuffer). |
1455 | (cvs-mode!) | |
ca98cd37 | 1456 | (let ((buf (cvs-temp-buffer "message" 'normal 'nosetup)) |
dedffa6a | 1457 | (setupfun (or (nth 2 (cdr (assoc "message" cvs-buffer-name-alist))) |
ca98cd37 | 1458 | 'log-edit))) |
11ee8d90 | 1459 | (funcall setupfun 'cvs-do-commit setup |
43202f8a DN |
1460 | '((log-edit-listfun . cvs-commit-filelist) |
1461 | (log-edit-diff-function . cvs-mode-diff)) buf) | |
ca98cd37 | 1462 | (set (make-local-variable 'cvs-minor-wrap-function) 'cvs-commit-minor-wrap) |
98a68b08 | 1463 | (run-hooks 'cvs-mode-commit-hook))) |
5b467bf4 SM |
1464 | |
1465 | (defun cvs-commit-minor-wrap (buf f) | |
1466 | (let ((cvs-ignore-marks-modif (cvs-mode-mark-get-modif "commit"))) | |
1467 | (funcall f))) | |
1468 | ||
598dd5ff SM |
1469 | (defun cvs-commit-filelist () |
1470 | (cvs-mode-files 'commit nil :read-only t :file t :noquery t)) | |
5b467bf4 SM |
1471 | |
1472 | (defun cvs-do-commit (flags) | |
1473 | "Do the actual commit, using the current buffer as the log message." | |
1474 | (interactive (list (cvs-flags-query 'cvs-commit-flags "cvs commit flags"))) | |
027b73ac | 1475 | (let ((msg (buffer-substring-no-properties (point-min) (point-max)))) |
5b467bf4 SM |
1476 | (cvs-mode!) |
1477 | ;;(pop-to-buffer cvs-buffer) | |
1478 | (cvs-mode-do "commit" (list* "-m" msg flags) 'commit))) | |
1479 | ||
1480 | ||
6b2e4334 SM |
1481 | ;;;; Editing existing commit log messages. |
1482 | ||
1483 | (defun cvs-edit-log-text-at-point () | |
1484 | (save-excursion | |
1485 | (end-of-line) | |
1486 | (when (re-search-backward "^revision " nil t) | |
1487 | (forward-line 1) | |
1488 | (if (looking-at "date:") (forward-line 1)) | |
1489 | (if (looking-at "branches:") (forward-line 1)) | |
1490 | (buffer-substring | |
1491 | (point) | |
1492 | (if (re-search-forward | |
1493 | "^\\(-\\{28\\}\\|=\\{77\\}\\|revision [.0-9]+\\)$" | |
1494 | nil t) | |
1495 | (match-beginning 0) | |
1496 | (point)))))) | |
1497 | ||
6a26cf4a | 1498 | (defvar cvs-edit-log-revision) |
bad3da7a SM |
1499 | (defvar cvs-edit-log-files) (put 'cvs-edit-log-files 'permanent-local t) |
1500 | (defun cvs-mode-edit-log (file rev &optional text) | |
6b2e4334 SM |
1501 | "Edit the log message at point. |
1502 | This is best called from a `log-view-mode' buffer." | |
1503 | (interactive | |
1504 | (list | |
bad3da7a SM |
1505 | (or (cvs-mode! (lambda () |
1506 | (car (cvs-mode-files nil nil | |
1507 | :read-only t :file t :noquery t)))) | |
1508 | (read-string "File name: ")) | |
6b2e4334 SM |
1509 | (or (cvs-mode! (lambda () (cvs-prefix-get 'cvs-branch-prefix))) |
1510 | (read-string "Revision to edit: ")) | |
1511 | (cvs-edit-log-text-at-point))) | |
1512 | ;; It seems that the save-excursion that happens if I use the better | |
1513 | ;; form of `(cvs-mode! (lambda ...))' screws up a couple things which | |
1514 | ;; end up being rather annoying (like log-edit-mode's message being | |
1515 | ;; displayed in the wrong minibuffer). | |
1516 | (cvs-mode!) | |
1517 | (let ((buf (cvs-temp-buffer "message" 'normal 'nosetup)) | |
6b2e4334 SM |
1518 | (setupfun (or (nth 2 (cdr (assoc "message" cvs-buffer-name-alist))) |
1519 | 'log-edit))) | |
bad3da7a SM |
1520 | (with-current-buffer buf |
1521 | ;; Set the filename before, so log-edit can correctly setup its | |
1522 | ;; log-edit-initial-files variable. | |
1523 | (set (make-local-variable 'cvs-edit-log-files) (list file))) | |
11ee8d90 | 1524 | (funcall setupfun 'cvs-do-edit-log nil |
43202f8a DN |
1525 | '((log-edit-listfun . cvs-edit-log-filelist) |
1526 | (log-edit-diff-function . cvs-mode-diff)) | |
1527 | buf) | |
6b2e4334 SM |
1528 | (when text (erase-buffer) (insert text)) |
1529 | (set (make-local-variable 'cvs-edit-log-revision) rev) | |
bad3da7a SM |
1530 | (set (make-local-variable 'cvs-minor-wrap-function) |
1531 | 'cvs-edit-log-minor-wrap) | |
6b2e4334 SM |
1532 | ;; (run-hooks 'cvs-mode-commit-hook) |
1533 | )) | |
1534 | ||
1535 | (defun cvs-edit-log-minor-wrap (buf f) | |
bad3da7a SM |
1536 | (let ((cvs-branch-prefix (with-current-buffer buf cvs-edit-log-revision)) |
1537 | (cvs-minor-current-files | |
1538 | (with-current-buffer buf cvs-edit-log-files)) | |
1539 | ;; FIXME: I need to force because the fileinfos are UNKNOWN | |
1540 | (cvs-force-command "/F")) | |
6b2e4334 SM |
1541 | (funcall f))) |
1542 | ||
1543 | (defun cvs-edit-log-filelist () | |
bad3da7a SM |
1544 | (if cvs-minor-wrap-function |
1545 | (cvs-mode-files nil nil :read-only t :file t :noquery t) | |
1546 | cvs-edit-log-files)) | |
6b2e4334 SM |
1547 | |
1548 | (defun cvs-do-edit-log (rev) | |
1549 | "Do the actual commit, using the current buffer as the log message." | |
1550 | (interactive (list cvs-edit-log-revision)) | |
1551 | (let ((msg (buffer-substring-no-properties (point-min) (point-max)))) | |
bad3da7a SM |
1552 | (cvs-mode! |
1553 | (lambda () | |
1554 | (cvs-mode-do "admin" (list (concat "-m" rev ":" msg)) nil))))) | |
6b2e4334 SM |
1555 | |
1556 | ||
027b73ac | 1557 | ;;;; |
5b467bf4 | 1558 | ;;;; CVS Mode commands |
027b73ac | 1559 | ;;;; |
5b467bf4 SM |
1560 | |
1561 | (defun-cvs-mode (cvs-mode-insert . NOARGS) (file) | |
883e7198 SM |
1562 | "Insert an entry for a specific file into the current listing. |
1563 | This is typically used if the file is up-to-date (or has been added | |
1564 | outside of PCL-CVS) and one wants to do some operation on it." | |
5b467bf4 | 1565 | (interactive |
be0add30 SM |
1566 | (list (read-file-name |
1567 | "File to insert: " | |
1568 | ;; Can't use ignore-errors here because interactive | |
1569 | ;; specs aren't byte-compiled. | |
1570 | (condition-case nil | |
1571 | (file-name-as-directory | |
1572 | (expand-file-name | |
1573 | (cvs-fileinfo->dir | |
1574 | (cvs-mode-marked nil nil :read-only t :one t :noquery t)))) | |
1575 | (error nil))))) | |
316e1d5b SM |
1576 | (cvs-insert-file file)) |
1577 | ||
1578 | (defun cvs-insert-file (file) | |
1579 | "Insert FILE (and its contents if it's a dir) and return its FI." | |
6dc7d3d5 SM |
1580 | (let ((file (file-relative-name (directory-file-name file))) last) |
1581 | (dolist (fi (cvs-fileinfo-from-entries file)) | |
3c7fafc7 SM |
1582 | (setq last (cvs-addto-collection cvs-cookies fi last))) |
1583 | ;; There should have been at least one entry. | |
316e1d5b SM |
1584 | (goto-char (ewoc-location last)) |
1585 | (ewoc-data last))) | |
5b467bf4 | 1586 | |
274d02f7 SM |
1587 | (defun cvs-mark-fis-dead (fis) |
1588 | ;; Helper function, introduced because of the need for macro-expansion. | |
1589 | (dolist (fi fis) | |
1590 | (setf (cvs-fileinfo->type fi) 'DEAD))) | |
1591 | ||
5b467bf4 SM |
1592 | (defun-cvs-mode (cvs-mode-add . SIMPLE) (flags) |
1593 | "Add marked files to the cvs repository. | |
1594 | With prefix argument, prompt for cvs flags." | |
1595 | (interactive (list (cvs-flags-query 'cvs-add-flags "cvs add flags"))) | |
1596 | (let ((fis (cvs-mode-marked 'add)) | |
1597 | (needdesc nil) (dirs nil)) | |
1598 | ;; find directories and look for fis needing a description | |
1599 | (dolist (fi fis) | |
1600 | (cond | |
2231c2bc | 1601 | ((file-directory-p (cvs-fileinfo->full-name fi)) (push fi dirs)) |
5b467bf4 SM |
1602 | ((eq (cvs-fileinfo->type fi) 'UNKNOWN) (setq needdesc t)))) |
1603 | ;; prompt for description if necessary | |
1604 | (let* ((msg (if (and needdesc | |
1605 | (or current-prefix-arg (not cvs-add-default-message))) | |
1606 | (read-from-minibuffer "Enter description: ") | |
1607 | (or cvs-add-default-message ""))) | |
1608 | (flags (list* "-m" msg flags)) | |
1609 | (postproc | |
1610 | ;; setup postprocessing for the directory entries | |
1611 | (when dirs | |
1612 | `((cvs-run-process (list "-n" "update") | |
1613 | ',dirs | |
1614 | '(cvs-parse-process t)) | |
274d02f7 | 1615 | (cvs-mark-fis-dead ',dirs))))) |
5b467bf4 SM |
1616 | (cvs-mode-run "add" flags fis :postproc postproc)))) |
1617 | ||
5b467bf4 SM |
1618 | (defun-cvs-mode (cvs-mode-diff . DOUBLE) (flags) |
1619 | "Diff the selected files against the repository. | |
1620 | This command compares the files in your working area against the | |
1621 | revision which they are based upon." | |
1622 | (interactive | |
1623 | (list (cvs-add-branch-prefix | |
1624 | (cvs-add-secondary-branch-prefix | |
1625 | (cvs-flags-query 'cvs-diff-flags "cvs diff flags"))))) | |
1626 | (cvs-mode-do "diff" flags 'diff | |
1627 | :show t)) ;; :ignore-exit t | |
1628 | ||
5b467bf4 SM |
1629 | (defun-cvs-mode (cvs-mode-diff-head . SIMPLE) (flags) |
1630 | "Diff the selected files against the head of the current branch. | |
1631 | See ``cvs-mode-diff'' for more info." | |
1632 | (interactive (list (cvs-flags-query 'cvs-diff-flags "cvs diff flags"))) | |
1633 | (cvs-mode-diff-1 (cons "-rHEAD" flags))) | |
1634 | ||
9ff78fed JL |
1635 | (defun-cvs-mode (cvs-mode-diff-repository . SIMPLE) (flags) |
1636 | "Diff the files for changes in the repository since last co/update/commit. | |
1637 | See ``cvs-mode-diff'' for more info." | |
1638 | (interactive (list (cvs-flags-query 'cvs-diff-flags "cvs diff flags"))) | |
1639 | (cvs-mode-diff-1 (cons "-rBASE" (cons "-rHEAD" flags)))) | |
1640 | ||
a9b10468 KS |
1641 | (defun-cvs-mode (cvs-mode-diff-yesterday . SIMPLE) (flags) |
1642 | "Diff the selected files against yesterday's head of the current branch. | |
1643 | See ``cvs-mode-diff'' for more info." | |
1644 | (interactive (list (cvs-flags-query 'cvs-diff-flags "cvs diff flags"))) | |
1645 | (cvs-mode-diff-1 (cons "-Dyesterday" flags))) | |
1646 | ||
5b467bf4 SM |
1647 | (defun-cvs-mode (cvs-mode-diff-vendor . SIMPLE) (flags) |
1648 | "Diff the selected files against the head of the vendor branch. | |
1649 | See ``cvs-mode-diff'' for more info." | |
1650 | (interactive (list (cvs-flags-query 'cvs-diff-flags "cvs diff flags"))) | |
1651 | (cvs-mode-diff-1 (cons (concat "-r" cvs-vendor-branch) flags))) | |
1652 | ||
5b467bf4 SM |
1653 | ;; sadly, this is not provided by cvs, so we have to roll our own |
1654 | (defun-cvs-mode (cvs-mode-diff-backup . SIMPLE) (flags) | |
1655 | "Diff the files against the backup file. | |
1656 | This command can be used on files that are marked with \"Merged\" | |
1657 | or \"Conflict\" in the *cvs* buffer." | |
1658 | (interactive (list (cvs-flags-query 'cvs-diff-flags "diff flags"))) | |
3afbc435 | 1659 | (unless (listp flags) (error "flags should be a list of strings")) |
5b467bf4 | 1660 | (save-some-buffers) |
6a26cf4a | 1661 | (let* ((marked (cvs-get-marked (cvs-ignore-marks-p "diff"))) |
598dd5ff | 1662 | (fis (car (cvs-partition 'cvs-fileinfo->backup-file marked)))) |
5b467bf4 | 1663 | (unless (consp fis) |
316e1d5b | 1664 | (error "No files with a backup file selected!")) |
5b467bf4 SM |
1665 | ;; let's extract some info into the environment for `buffer-name' |
1666 | (let* ((dir (cvs-fileinfo->dir (car fis))) | |
1667 | (file (cvs-fileinfo->file (car fis)))) | |
1668 | (set-buffer (cvs-temp-buffer "diff"))) | |
1669 | (message "cvs diff backup...") | |
1670 | (cvs-execute-single-file-list fis 'cvs-diff-backup-extractor | |
1671 | cvs-diff-program flags)) | |
1672 | (message "cvs diff backup... Done.")) | |
1673 | ||
5b467bf4 SM |
1674 | (defun cvs-diff-backup-extractor (fileinfo) |
1675 | "Return the filename and the name of the backup file as a list. | |
1676 | Signal an error if there is no backup file." | |
1677 | (let ((backup-file (cvs-fileinfo->backup-file fileinfo))) | |
1678 | (unless backup-file | |
2231c2bc SM |
1679 | (error "%s has no backup file" (cvs-fileinfo->full-name fileinfo))) |
1680 | (list backup-file (cvs-fileinfo->full-name fileinfo)))) | |
5b467bf4 SM |
1681 | |
1682 | ;; | |
1683 | ;; Emerge support | |
1684 | ;; | |
1685 | (defun cvs-emerge-diff (b1 b2) (emerge-buffers b1 b2 b1)) | |
1686 | (defun cvs-emerge-merge (b1 b2 base out) | |
1687 | (emerge-buffers-with-ancestor b1 b2 base (find-file-noselect out))) | |
1688 | ||
1689 | ;; | |
1690 | ;; Ediff support | |
027b73ac | 1691 | ;; |
5b467bf4 SM |
1692 | |
1693 | (defvar ediff-after-quit-destination-buffer) | |
6a26cf4a | 1694 | (defvar ediff-after-quit-hook-internal) |
5b467bf4 SM |
1695 | (defvar cvs-transient-buffers) |
1696 | (defun cvs-ediff-startup-hook () | |
1697 | (add-hook 'ediff-after-quit-hook-internal | |
1698 | `(lambda () | |
1699 | (cvs-ediff-exit-hook | |
1700 | ',ediff-after-quit-destination-buffer ',cvs-transient-buffers)) | |
1701 | nil 'local)) | |
1702 | ||
1703 | (defun cvs-ediff-exit-hook (cvs-buf tmp-bufs) | |
1704 | ;; kill the temp buffers (and their associated windows) | |
1705 | (dolist (tb tmp-bufs) | |
1706 | (when (and tb (buffer-live-p tb) (not (buffer-modified-p tb))) | |
1707 | (let ((win (get-buffer-window tb t))) | |
a7996e05 | 1708 | (kill-buffer tb) |
eed914af | 1709 | (when (window-live-p win) (ignore-errors (delete-window win)))))) |
5b467bf4 SM |
1710 | ;; switch back to the *cvs* buffer |
1711 | (when (and cvs-buf (buffer-live-p cvs-buf) | |
1712 | (not (get-buffer-window cvs-buf t))) | |
1713 | (ignore-errors (switch-to-buffer cvs-buf)))) | |
1714 | ||
1715 | (defun cvs-ediff-diff (b1 b2) | |
1716 | (let ((ediff-after-quit-destination-buffer (current-buffer)) | |
1717 | (startup-hook '(cvs-ediff-startup-hook))) | |
a7996e05 | 1718 | (ediff-buffers b1 b2 startup-hook 'ediff-revision))) |
5b467bf4 SM |
1719 | |
1720 | (defun cvs-ediff-merge (b1 b2 base out) | |
1721 | (let ((ediff-after-quit-destination-buffer (current-buffer)) | |
1722 | (startup-hook '(cvs-ediff-startup-hook))) | |
1723 | (ediff-merge-buffers-with-ancestor | |
1724 | b1 b2 base startup-hook | |
1725 | 'ediff-merge-revisions-with-ancestor | |
1726 | out))) | |
1727 | ||
1728 | ;; | |
1729 | ;; Interactive merge/diff support. | |
1730 | ;; | |
1731 | ||
1732 | (defun cvs-retrieve-revision (fileinfo rev) | |
1733 | "Retrieve the given REVision of the file in FILEINFO into a new buffer." | |
2231c2bc | 1734 | (let* ((file (cvs-fileinfo->full-name fileinfo)) |
eed914af SM |
1735 | (buffile (concat file "." rev))) |
1736 | (or (find-buffer-visiting buffile) | |
1737 | (with-current-buffer (create-file-buffer buffile) | |
1738 | (message "Retrieving revision %s..." rev) | |
906cbe45 SM |
1739 | ;; Discard stderr output to work around the CVS+SSH+libc |
1740 | ;; problem when stdout and stderr are the same. | |
608f2671 SM |
1741 | (let ((res |
1742 | (let ((coding-system-for-read 'binary)) | |
62b84d36 | 1743 | (apply 'process-file cvs-program nil '(t nil) nil |
608f2671 SM |
1744 | "-q" "update" "-p" |
1745 | ;; If `rev' is HEAD, don't pass it at all: | |
1746 | ;; the default behavior is to get the head | |
1747 | ;; of the current branch whereas "-r HEAD" | |
1748 | ;; stupidly gives you the head of the trunk. | |
1749 | (append (unless (equal rev "HEAD") (list "-r" rev)) | |
1750 | (list file)))))) | |
eed914af SM |
1751 | (when (and res (not (and (equal 0 res)))) |
1752 | (error "Something went wrong retrieving revision %s: %s" rev res)) | |
608f2671 SM |
1753 | ;; Figure out the encoding used and decode the byte-sequence |
1754 | ;; into a sequence of chars. | |
1755 | (decode-coding-inserted-region | |
1756 | (point-min) (point-max) file t nil nil t) | |
3c5471b8 SM |
1757 | ;; Set buffer-file-coding-system. |
1758 | (after-insert-file-set-coding (buffer-size) t) | |
eed914af SM |
1759 | (set-buffer-modified-p nil) |
1760 | (let ((buffer-file-name (expand-file-name file))) | |
1761 | (after-find-file)) | |
1762 | (toggle-read-only 1) | |
1763 | (message "Retrieving revision %s... Done" rev) | |
1764 | (current-buffer)))))) | |
5b467bf4 | 1765 | |
6dc7d3d5 SM |
1766 | ;; FIXME: The user should be able to specify ancestor/head/backup and we should |
1767 | ;; provide sensible defaults when merge info is unavailable (rather than rely | |
1768 | ;; on smerge-ediff). Also provide sane defaults for need-merge files. | |
5b467bf4 SM |
1769 | (defun-cvs-mode cvs-mode-imerge () |
1770 | "Merge interactively appropriate revisions of the selected file." | |
1771 | (interactive) | |
1772 | (let ((fi (cvs-mode-marked 'merge nil :one t :file t))) | |
1773 | (let ((merge (cvs-fileinfo->merge fi)) | |
2231c2bc | 1774 | (file (cvs-fileinfo->full-name fi)) |
5b467bf4 SM |
1775 | (backup-file (cvs-fileinfo->backup-file fi))) |
1776 | (if (not (and merge backup-file)) | |
1777 | (let ((buf (find-file-noselect file))) | |
1778 | (message "Missing merge info or backup file, using VC.") | |
6dc7d3d5 SM |
1779 | (with-current-buffer buf |
1780 | (smerge-ediff))) | |
5b467bf4 SM |
1781 | (let* ((ancestor-buf (cvs-retrieve-revision fi (car merge))) |
1782 | (head-buf (cvs-retrieve-revision fi (cdr merge))) | |
1783 | (backup-buf (let ((auto-mode-alist nil)) | |
1784 | (find-file-noselect backup-file))) | |
1785 | ;; this binding is used by cvs-ediff-startup-hook | |
1786 | (cvs-transient-buffers (list ancestor-buf backup-buf head-buf))) | |
1787 | (with-current-buffer backup-buf | |
1788 | (let ((buffer-file-name (expand-file-name file))) | |
1789 | (after-find-file))) | |
1790 | (funcall (cdr cvs-idiff-imerge-handlers) | |
1791 | backup-buf head-buf ancestor-buf file)))))) | |
1792 | ||
1793 | (cvs-flags-define cvs-idiff-version | |
1794 | (list "BASE" cvs-vendor-branch cvs-vendor-branch "BASE" "BASE") | |
1795 | "version: " cvs-qtypedesc-tag) | |
1796 | ||
1797 | (defun-cvs-mode (cvs-mode-idiff . NOARGS) (&optional rev1 rev2) | |
1798 | "Diff interactively current file to revisions." | |
1799 | (interactive | |
1800 | (let* ((rev1 (cvs-prefix-get 'cvs-branch-prefix)) | |
1801 | (rev2 (and rev1 (cvs-prefix-get 'cvs-secondary-branch-prefix)))) | |
1802 | (list (or rev1 (cvs-flags-query 'cvs-idiff-version)) | |
1803 | rev2))) | |
1804 | (let ((fi (cvs-mode-marked 'diff "idiff" :one t :file t))) | |
2231c2bc | 1805 | (let* ((file (cvs-fileinfo->full-name fi)) |
5b467bf4 SM |
1806 | (rev1-buf (cvs-retrieve-revision fi (or rev1 "BASE"))) |
1807 | (rev2-buf (if rev2 (cvs-retrieve-revision fi rev2))) | |
1808 | ;; this binding is used by cvs-ediff-startup-hook | |
1809 | (cvs-transient-buffers (list rev1-buf rev2-buf))) | |
316e1d5b SM |
1810 | (funcall (car cvs-idiff-imerge-handlers) |
1811 | rev1-buf (or rev2-buf (find-file-noselect file)))))) | |
5b467bf4 SM |
1812 | |
1813 | (defun-cvs-mode (cvs-mode-idiff-other . NOARGS) () | |
1814 | "Diff interactively current file to revisions." | |
1815 | (interactive) | |
1816 | (let* ((rev1 (cvs-prefix-get 'cvs-branch-prefix)) | |
1817 | (rev2 (and rev1 (cvs-prefix-get 'cvs-secondary-branch-prefix))) | |
1818 | (fis (cvs-mode-marked 'diff "idiff" :file t))) | |
1819 | (when (> (length fis) 2) | |
3afbc435 | 1820 | (error "idiff-other cannot be applied to more than 2 files at a time")) |
44946a4c | 1821 | (let* ((fi1 (car fis)) |
5b467bf4 | 1822 | (rev1-buf (if rev1 (cvs-retrieve-revision fi1 rev1) |
2231c2bc | 1823 | (find-file-noselect (cvs-fileinfo->full-name fi1)))) |
5b467bf4 SM |
1824 | rev2-buf) |
1825 | (if (cdr fis) | |
dedffa6a | 1826 | (let ((fi2 (nth 1 fis))) |
5b467bf4 SM |
1827 | (setq rev2-buf |
1828 | (if rev2 (cvs-retrieve-revision fi2 rev2) | |
2231c2bc | 1829 | (find-file-noselect (cvs-fileinfo->full-name fi2))))) |
3afbc435 | 1830 | (error "idiff-other doesn't know what other file/buffer to use")) |
5b467bf4 SM |
1831 | (let* (;; this binding is used by cvs-ediff-startup-hook |
1832 | (cvs-transient-buffers (list rev1-buf rev2-buf))) | |
1833 | (funcall (car cvs-idiff-imerge-handlers) | |
1834 | rev1-buf rev2-buf))))) | |
1835 | ||
1836 | ||
cb3430a1 | 1837 | (defun cvs-is-within-p (fis dir) |
f009f3bc | 1838 | "Non-nil if buffer is inside one of FIS (in DIR)." |
cb3430a1 SM |
1839 | (when (stringp buffer-file-name) |
1840 | (setq buffer-file-name (expand-file-name buffer-file-name)) | |
1841 | (let (ret) | |
1842 | (dolist (fi (or fis (list (cvs-create-fileinfo 'DIRCHANGE "" "." "")))) | |
1843 | (when (cvs-string-prefix-p | |
2231c2bc | 1844 | (expand-file-name (cvs-fileinfo->full-name fi) dir) |
cb3430a1 SM |
1845 | buffer-file-name) |
1846 | (setq ret t))) | |
1847 | ret))) | |
1848 | ||
5b467bf4 SM |
1849 | (defun* cvs-mode-run (cmd flags fis |
1850 | &key (buf (cvs-temp-buffer)) | |
1851 | dont-change-disc cvsargs postproc) | |
1852 | "Generic cvs-mode-<foo> function. | |
1853 | Executes `cvs CVSARGS CMD FLAGS FIS'. | |
1854 | BUF is the buffer to be used for cvs' output. | |
1855 | DONT-CHANGE-DISC non-nil indicates that the command will not change the | |
1856 | contents of files. This is only used by the parser. | |
1857 | POSTPROC is a list of expressions to be evaluated at the very end (after | |
f009f3bc | 1858 | parsing if applicable). It will be prepended with `progn' if necessary." |
cb3430a1 SM |
1859 | (let ((def-dir default-directory)) |
1860 | ;; Save the relevant buffers | |
1861 | (save-some-buffers nil (lambda () (cvs-is-within-p fis def-dir)))) | |
5b467bf4 | 1862 | (unless (listp flags) (error "flags should be a list of strings")) |
30c91af1 SM |
1863 | ;; Some w32 versions of CVS don't like an explicit . too much. |
1864 | (when (and (car fis) (null (cdr fis)) | |
1865 | (eq (cvs-fileinfo->type (car fis)) 'DIRCHANGE) | |
1866 | ;; (equal (cvs-fileinfo->file (car fis)) ".") | |
1867 | (equal (cvs-fileinfo->dir (car fis)) "")) | |
1868 | (setq fis nil)) | |
6a26cf4a | 1869 | (let* ((single-dir (or (not (listp cvs-execute-single-dir)) |
5b467bf4 SM |
1870 | (member cmd cvs-execute-single-dir))) |
1871 | (parse (member cmd cvs-parse-known-commands)) | |
1872 | (args (append cvsargs (list cmd) flags)) | |
dedffa6a | 1873 | (after-mode (nth 2 (cdr (assoc cmd cvs-buffer-name-alist))))) |
5b467bf4 SM |
1874 | (cvs-cleanup-collection cvs-cookies ;cleanup remaining messages |
1875 | (eq cvs-auto-remove-handled 'delayed) nil t) | |
1876 | (when (fboundp after-mode) | |
1877 | (setq postproc (append postproc `((,after-mode))))) | |
a399e814 SM |
1878 | (when parse |
1879 | (let ((old-fis | |
1880 | (when (member cmd '("status" "update")) ;FIXME: Yuck!! | |
1881 | ;; absence of `cvs update' output has a specific meaning. | |
1882 | (or fis (list (cvs-create-fileinfo 'DIRCHANGE "" "." "")))))) | |
1883 | (push `(cvs-parse-process ',dont-change-disc nil ',old-fis) postproc))) | |
5b467bf4 | 1884 | (setq postproc (if (cdr postproc) (cons 'progn postproc) (car postproc))) |
5b467bf4 | 1885 | (with-current-buffer buf |
5b467bf4 SM |
1886 | (let ((inhibit-read-only t)) (erase-buffer)) |
1887 | (message "Running cvs %s ..." cmd) | |
1888 | (cvs-run-process args fis postproc single-dir)))) | |
1889 | ||
1890 | ||
1891 | (defun* cvs-mode-do (cmd flags filter | |
6a26cf4a | 1892 | &key show dont-change-disc cvsargs postproc) |
5b467bf4 SM |
1893 | "Generic cvs-mode-<foo> function. |
1894 | Executes `cvs CVSARGS CMD FLAGS' on the selected files. | |
1895 | FILTER is passed to `cvs-applicable-p' to only apply the command to | |
1896 | files for which it makes sense. | |
1897 | SHOW indicates that CMD should be not be run in the default temp buffer and | |
1898 | should be shown to the user. The buffer and mode to be used is determined | |
1899 | by `cvs-buffer-name-alist'. | |
1900 | DONT-CHANGE-DISC non-nil indicates that the command will not change the | |
1901 | contents of files. This is only used by the parser." | |
1902 | (cvs-mode-run cmd flags (cvs-mode-marked filter cmd) | |
1903 | :buf (cvs-temp-buffer (when show cmd)) | |
1904 | :dont-change-disc dont-change-disc | |
1905 | :cvsargs cvsargs | |
1906 | :postproc postproc)) | |
1907 | ||
1908 | (defun-cvs-mode (cvs-mode-status . SIMPLE) (flags) | |
1909 | "Show cvs status for all marked files. | |
1910 | With prefix argument, prompt for cvs flags." | |
1911 | (interactive (list (cvs-flags-query 'cvs-status-flags "cvs status flags"))) | |
1912 | (cvs-mode-do "status" flags nil :dont-change-disc t :show t | |
1913 | :postproc (when (eq cvs-auto-remove-handled 'status) | |
f5120547 | 1914 | `((with-current-buffer ,(current-buffer) |
5b467bf4 SM |
1915 | (cvs-mode-remove-handled)))))) |
1916 | ||
1917 | (defun-cvs-mode (cvs-mode-tree . SIMPLE) (flags) | |
1918 | "Call cvstree using the file under the point as a keyfile." | |
1919 | (interactive (list (cvs-flags-query 'cvs-status-flags "cvs status flags"))) | |
1920 | (cvs-mode-run "status" (cons "-v" flags) (cvs-mode-marked nil "status") | |
1921 | :buf (cvs-temp-buffer "tree") | |
1922 | :dont-change-disc t | |
316e1d5b | 1923 | :postproc '((cvs-status-cvstrees)))) |
5b467bf4 SM |
1924 | |
1925 | ;; cvs log | |
1926 | ||
1927 | (defun-cvs-mode (cvs-mode-log . NOARGS) (flags) | |
1928 | "Display the cvs log of all selected files. | |
1929 | With prefix argument, prompt for cvs flags." | |
1930 | (interactive (list (cvs-add-branch-prefix | |
1931 | (cvs-flags-query 'cvs-log-flags "cvs log flags")))) | |
1932 | (cvs-mode-do "log" flags nil :show t)) | |
1933 | ||
1934 | ||
1935 | (defun-cvs-mode (cvs-mode-update . NOARGS) (flags) | |
1936 | "Update all marked files. | |
1937 | With a prefix argument, prompt for cvs flags." | |
1938 | (interactive | |
1939 | (list (cvs-add-branch-prefix | |
1940 | (cvs-add-secondary-branch-prefix | |
1941 | (cvs-flags-query 'cvs-update-flags "cvs update flags") | |
1942 | "-j") "-j"))) | |
1943 | (cvs-mode-do "update" flags 'update)) | |
1944 | ||
1945 | ||
1946 | (defun-cvs-mode (cvs-mode-examine . NOARGS) (flags) | |
1947 | "Re-examine all marked files. | |
1948 | With a prefix argument, prompt for cvs flags." | |
1949 | (interactive | |
1950 | (list (cvs-add-branch-prefix | |
1951 | (cvs-add-secondary-branch-prefix | |
1952 | (cvs-flags-query 'cvs-update-flags "cvs -n update flags") | |
1953 | "-j") "-j"))) | |
1954 | (cvs-mode-do "update" flags nil :cvsargs '("-n") :dont-change-disc t)) | |
1955 | ||
1956 | ||
1957 | (defun-cvs-mode cvs-mode-ignore (&optional pattern) | |
1958 | "Arrange so that CVS ignores the selected files. | |
1959 | This command ignores files that are not flagged as `Unknown'." | |
1960 | (interactive) | |
1961 | (dolist (fi (cvs-mode-marked 'ignore)) | |
1d2b9bba SM |
1962 | (cvs-append-to-ignore (cvs-fileinfo->dir fi) (cvs-fileinfo->file fi) |
1963 | (eq (cvs-fileinfo->subtype fi) 'NEW-DIR)) | |
5b467bf4 SM |
1964 | (setf (cvs-fileinfo->type fi) 'DEAD)) |
1965 | (cvs-cleanup-collection cvs-cookies nil nil nil)) | |
1966 | ||
cef8032b DN |
1967 | (declare-function vc-editable-p "vc" (file)) |
1968 | (declare-function vc-checkout "vc" (file &optional writable rev)) | |
5b467bf4 | 1969 | |
1d2b9bba SM |
1970 | (defun cvs-append-to-ignore (dir str &optional old-dir) |
1971 | "Add STR to the .cvsignore file in DIR. | |
1972 | If OLD-DIR is non-nil, then this is a directory that we don't want | |
1973 | to hear about anymore." | |
1974 | (with-current-buffer | |
1975 | (find-file-noselect (expand-file-name ".cvsignore" dir)) | |
5b467bf4 SM |
1976 | (when (ignore-errors |
1977 | (and buffer-read-only | |
1978 | (eq 'CVS (vc-backend buffer-file-name)) | |
d15c2aaa | 1979 | (not (vc-editable-p buffer-file-name)))) |
5b467bf4 | 1980 | ;; CVSREAD=on special case |
1d2b9bba | 1981 | (vc-checkout buffer-file-name t)) |
5b467bf4 | 1982 | (goto-char (point-max)) |
1d2b9bba SM |
1983 | (unless (bolp) (insert "\n")) |
1984 | (insert str (if old-dir "/\n" "\n")) | |
5b467bf4 SM |
1985 | (if cvs-sort-ignore-file (sort-lines nil (point-min) (point-max))) |
1986 | (save-buffer))) | |
1987 | ||
1988 | ||
1989 | (defun cvs-mode-find-file-other-window (e) | |
1990 | "Select a buffer containing the file in another window." | |
1991 | (interactive (list last-input-event)) | |
1992 | (cvs-mode-find-file e t)) | |
1993 | ||
1994 | ||
be0add30 SM |
1995 | (defun cvs-mode-display-file (e) |
1996 | "Show a buffer containing the file in another window." | |
1997 | (interactive (list last-input-event)) | |
1998 | (cvs-mode-find-file e 'dont-select)) | |
1999 | ||
2000 | ||
d12757b7 KS |
2001 | (defun cvs-mode-view-file (e) |
2002 | "View the file." | |
2003 | (interactive (list last-input-event)) | |
2004 | (cvs-mode-find-file e nil t)) | |
2005 | ||
2006 | ||
2007 | (defun cvs-mode-view-file-other-window (e) | |
2008 | "View the file." | |
2009 | (interactive (list last-input-event)) | |
2010 | (cvs-mode-find-file e t t)) | |
2011 | ||
2012 | ||
5b467bf4 SM |
2013 | (defun cvs-find-modif (fi) |
2014 | (with-temp-buffer | |
62b84d36 | 2015 | (process-file cvs-program nil (current-buffer) nil |
5b467bf4 SM |
2016 | "-f" "diff" (cvs-fileinfo->file fi)) |
2017 | (goto-char (point-min)) | |
2018 | (if (re-search-forward "^\\([0-9]+\\)" nil t) | |
2019 | (string-to-number (match-string 1)) | |
2020 | 1))) | |
2021 | ||
2022 | ||
d12757b7 | 2023 | (defun cvs-mode-find-file (e &optional other view) |
5b467bf4 SM |
2024 | "Select a buffer containing the file. |
2025 | With a prefix, opens the buffer in an OTHER window." | |
2026 | (interactive (list last-input-event current-prefix-arg)) | |
61454605 | 2027 | ;; If the event moves point, check that it moves it to a valid location. |
6dfa5acf | 2028 | (when (and (/= (point) (progn (posn-set-point (event-end e)) (point))) |
7b33268a SS |
2029 | (not (memq (get-text-property (1- (line-end-position)) |
2030 | 'font-lock-face) | |
94d5c876 | 2031 | '(cvs-header cvs-filename)))) |
61454605 | 2032 | (error "Not a file name")) |
5b467bf4 SM |
2033 | (cvs-mode! |
2034 | (lambda (&optional rev) | |
2035 | (interactive (list (cvs-prefix-get 'cvs-branch-prefix))) | |
2036 | (let* ((cvs-buf (current-buffer)) | |
2037 | (fi (cvs-mode-marked nil nil :one t))) | |
2038 | (if (eq (cvs-fileinfo->type fi) 'DIRCHANGE) | |
2039 | (let ((odir default-directory)) | |
2040 | (setq default-directory | |
2041 | (cvs-expand-dir-name (cvs-fileinfo->dir fi))) | |
be0add30 SM |
2042 | (cond ((eq other 'dont-select) |
2043 | (display-buffer (find-file-noselect default-directory))) | |
2044 | (other (dired-other-window default-directory)) | |
2045 | (t (dired default-directory))) | |
5b467bf4 SM |
2046 | (set-buffer cvs-buf) |
2047 | (setq default-directory odir)) | |
2048 | (let ((buf (if rev (cvs-retrieve-revision fi rev) | |
2231c2bc | 2049 | (find-file-noselect (cvs-fileinfo->full-name fi))))) |
be0add30 | 2050 | (funcall (cond ((eq other 'dont-select) 'display-buffer) |
d12757b7 KS |
2051 | (other |
2052 | (if view 'view-buffer-other-window | |
2053 | 'switch-to-buffer-other-window)) | |
2054 | (t (if view 'view-buffer 'switch-to-buffer))) | |
5b467bf4 SM |
2055 | buf) |
2056 | (when (and cvs-find-file-and-jump (cvs-applicable-p fi 'diff-base)) | |
9477096c GM |
2057 | (save-restriction |
2058 | (widen) | |
2059 | (goto-char (point-min)) | |
2060 | (forward-line (1- (cvs-find-modif fi))))) | |
5b467bf4 SM |
2061 | buf)))))) |
2062 | ||
2063 | ||
2064 | (defun-cvs-mode (cvs-mode-undo . SIMPLE) (flags) | |
2065 | "Undo local changes to all marked files. | |
2066 | The file is removed and `cvs update FILE' is run." | |
2067 | ;;"With prefix argument, prompt for cvs FLAGS." | |
2068 | (interactive (list nil));; (cvs-flags-query 'cvs-undo-flags "undo flags") | |
2069 | (if current-prefix-arg (call-interactively 'cvs-mode-revert-to-rev) | |
2070 | (let* ((fis (cvs-do-removal 'undo "update" 'all)) | |
6b2e4334 SM |
2071 | (removedp (lambda (fi) |
2072 | (or (eq (cvs-fileinfo->type fi) 'REMOVED) | |
2073 | (and (eq (cvs-fileinfo->type fi) 'CONFLICT) | |
2074 | (eq (cvs-fileinfo->subtype fi) 'REMOVED))))) | |
5b467bf4 SM |
2075 | (fis-split (cvs-partition removedp fis)) |
2076 | (fis-removed (car fis-split)) | |
2077 | (fis-other (cdr fis-split))) | |
2078 | (if (null fis-other) | |
2079 | (when fis-removed (cvs-mode-run "add" nil fis-removed)) | |
2080 | (cvs-mode-run "update" flags fis-other | |
2081 | :postproc | |
2082 | (when fis-removed | |
2083 | `((with-current-buffer ,(current-buffer) | |
2084 | (cvs-mode-run "add" nil ',fis-removed))))))))) | |
2085 | ||
2086 | ||
2087 | (defun-cvs-mode (cvs-mode-revert-to-rev . NOARGS) (rev) | |
2088 | "Revert the selected files to an old revision." | |
2089 | (interactive | |
2090 | (list (or (cvs-prefix-get 'cvs-branch-prefix) | |
2091 | (let ((current-prefix-arg '(4))) | |
2092 | (cvs-flags-query 'cvs-idiff-version))))) | |
2093 | (let* ((fis (cvs-mode-marked 'revert "revert" :file t)) | |
2094 | (tag (concat "tmp_pcl_tag_" (make-temp-name ""))) | |
2095 | (untag `((with-current-buffer ,(current-buffer) | |
2096 | (cvs-mode-run "tag" (list "-d" ',tag) ',fis)))) | |
2097 | (update `((with-current-buffer ,(current-buffer) | |
2098 | (cvs-mode-run "update" (list "-j" ',tag "-j" ',rev) ',fis | |
2099 | :postproc ',untag))))) | |
2100 | (cvs-mode-run "tag" (list tag) fis :postproc update))) | |
2101 | ||
2102 | ||
2103 | (defun-cvs-mode cvs-mode-delete-lock () | |
2104 | "Delete the lock file that CVS is waiting for. | |
2105 | Note that this can be dangerous. You should only do this | |
2106 | if you are convinced that the process that created the lock is dead." | |
2107 | (interactive) | |
2108 | (let* ((default-directory (cvs-expand-dir-name cvs-lock-file)) | |
2109 | (locks (directory-files default-directory nil cvs-lock-file-regexp))) | |
2110 | (cond | |
3afbc435 | 2111 | ((not locks) (error "No lock files found")) |
5b467bf4 SM |
2112 | ((yes-or-no-p (concat "Really delete locks in " cvs-lock-file "? ")) |
2113 | (dolist (lock locks) | |
2114 | (cond ((file-directory-p lock) (delete-directory lock)) | |
2115 | ((file-exists-p lock) (delete-file lock)))))))) | |
2116 | ||
2117 | ||
2118 | (defun-cvs-mode cvs-mode-remove-handled () | |
2119 | "Remove all lines that are handled. | |
2120 | Empty directories are removed." | |
2121 | (interactive) | |
2122 | (cvs-cleanup-collection cvs-cookies | |
2123 | t (or cvs-auto-remove-directories 'handled) t)) | |
2124 | ||
2125 | ||
2126 | (defun-cvs-mode cvs-mode-acknowledge () | |
2127 | "Remove all marked files from the buffer." | |
2128 | (interactive) | |
2129 | (dolist (fi (cvs-get-marked (cvs-ignore-marks-p "acknowledge") t)) | |
2130 | (setf (cvs-fileinfo->type fi) 'DEAD)) | |
2131 | (cvs-cleanup-collection cvs-cookies nil nil nil)) | |
2132 | ||
5b467bf4 SM |
2133 | (defun cvs-do-removal (filter &optional cmd all) |
2134 | "Remove files. | |
2135 | Returns a list of FIS that should be `cvs remove'd." | |
2136 | (let* ((files (cvs-mode-marked filter cmd :file t :read-only t)) | |
598dd5ff SM |
2137 | (fis (cdr (cvs-partition (lambda (fi) |
2138 | (eq (cvs-fileinfo->type fi) 'UNKNOWN)) | |
2139 | (cvs-mode-marked filter cmd)))) | |
5b467bf4 SM |
2140 | (silent (or (not cvs-confirm-removals) |
2141 | (cvs-every (lambda (fi) | |
2142 | (or (not (file-exists-p | |
2231c2bc | 2143 | (cvs-fileinfo->full-name fi))) |
5b467bf4 | 2144 | (cvs-applicable-p fi 'safe-rm))) |
598dd5ff SM |
2145 | files))) |
2146 | (tmpbuf (cvs-temp-buffer))) | |
5b467bf4 | 2147 | (when (and (not silent) (equal cvs-confirm-removals 'list)) |
598dd5ff | 2148 | (with-current-buffer tmpbuf |
3f1045d5 | 2149 | (let ((inhibit-read-only t)) |
2231c2bc | 2150 | (cvs-insert-strings (mapcar 'cvs-fileinfo->full-name fis)) |
3f1045d5 SM |
2151 | (cvs-pop-to-buffer-same-frame (current-buffer)) |
2152 | (shrink-window-if-larger-than-buffer)))) | |
5b467bf4 | 2153 | (if (not (or silent |
598dd5ff | 2154 | (unwind-protect |
d3ffebbc | 2155 | (yes-or-no-p |
9ceda1bb MY |
2156 | (let ((nfiles (length files)) |
2157 | (verb (if (eq filter 'undo) "Undo" "Delete"))) | |
bb61abb8 | 2158 | (if (= 1 nfiles) |
d3ffebbc | 2159 | (format "%s file: \"%s\" ? " |
9ceda1bb | 2160 | verb |
bb61abb8 | 2161 | (cvs-fileinfo->file (car files))) |
d3ffebbc | 2162 | (format "%s %d files? " |
9ceda1bb MY |
2163 | verb |
2164 | nfiles)))) | |
598dd5ff | 2165 | (cvs-bury-buffer tmpbuf cvs-buffer)))) |
5b467bf4 SM |
2166 | (progn (message "Aborting") nil) |
2167 | (dolist (fi files) | |
2168 | (let* ((type (cvs-fileinfo->type fi)) | |
2231c2bc | 2169 | (file (cvs-fileinfo->full-name fi))) |
5b467bf4 SM |
2170 | (when (or all (eq type 'UNKNOWN)) |
2171 | (when (file-exists-p file) (delete-file file)) | |
2172 | (unless all (setf (cvs-fileinfo->type fi) 'DEAD) t)))) | |
2173 | fis))) | |
2174 | ||
2175 | (defun-cvs-mode (cvs-mode-remove . SIMPLE) (flags) | |
2176 | "Remove all marked files. | |
2177 | With prefix argument, prompt for cvs flags." | |
2178 | (interactive (list (cvs-flags-query 'cvs-remove-flags "cvs remove flags"))) | |
2179 | (let ((fis (cvs-do-removal 'remove))) | |
2180 | (if fis (cvs-mode-run "remove" (cons "-f" flags) fis) | |
2181 | (cvs-cleanup-collection cvs-cookies nil nil nil)))) | |
2182 | ||
2183 | ||
2184 | (defvar cvs-tag-name "") | |
2185 | (defun-cvs-mode (cvs-mode-tag . SIMPLE) (tag &optional flags) | |
2186 | "Run `cvs tag TAG' on all selected files. | |
7b004f77 SM |
2187 | With prefix argument, prompt for cvs flags. |
2188 | By default this can only be used on directories. | |
2189 | Use \\[cvs-mode-force-command] or change `cvs-force-dir-tag' if you need | |
2190 | to use it on individual files." | |
5b467bf4 SM |
2191 | (interactive |
2192 | (list (setq cvs-tag-name | |
2193 | (cvs-query-read cvs-tag-name "Tag name: " cvs-qtypedesc-tag)) | |
2194 | (cvs-flags-query 'cvs-tag-flags "tag flags"))) | |
2195 | (cvs-mode-do "tag" (append flags (list tag)) | |
2196 | (when cvs-force-dir-tag 'tag))) | |
2197 | ||
2198 | (defun-cvs-mode (cvs-mode-untag . SIMPLE) (tag &optional flags) | |
2199 | "Run `cvs tag -d TAG' on all selected files. | |
2200 | With prefix argument, prompt for cvs flags." | |
2201 | (interactive | |
2202 | (list (setq cvs-tag-name | |
2203 | (cvs-query-read cvs-tag-name "Tag to delete: " cvs-qtypedesc-tag)) | |
2204 | (cvs-flags-query 'cvs-tag-flags "tag flags"))) | |
2205 | (cvs-mode-do "tag" (append '("-d") flags (list tag)) | |
2206 | (when cvs-force-dir-tag 'tag))) | |
027b73ac | 2207 | |
5b467bf4 SM |
2208 | |
2209 | ;; Byte compile files. | |
2210 | ||
2211 | (defun-cvs-mode cvs-mode-byte-compile-files () | |
2212 | "Run byte-compile-file on all selected files that end in '.el'." | |
2213 | (interactive) | |
2214 | (let ((marked (cvs-get-marked (cvs-ignore-marks-p "byte-compile")))) | |
2215 | (dolist (fi marked) | |
2231c2bc | 2216 | (let ((filename (cvs-fileinfo->full-name fi))) |
5b467bf4 SM |
2217 | (when (string-match "\\.el\\'" filename) |
2218 | (byte-compile-file filename)))))) | |
2219 | ||
2220 | ;; ChangeLog support. | |
2221 | ||
5b467bf4 SM |
2222 | (defun-cvs-mode cvs-mode-add-change-log-entry-other-window () |
2223 | "Add a ChangeLog entry in the ChangeLog of the current directory." | |
2224 | (interactive) | |
fd071fdf SM |
2225 | ;; Require `add-log' explicitly, because if it gets autoloaded when we call |
2226 | ;; add-change-log-entry-other-window below, the | |
2227 | ;; add-log-buffer-file-name-function ends up unbound when we leave the `let'. | |
2228 | (require 'add-log) | |
883e7198 | 2229 | (dolist (fi (cvs-mode-marked nil nil)) |
cd07ee90 | 2230 | (let* ((default-directory (cvs-expand-dir-name (cvs-fileinfo->dir fi))) |
fd071fdf SM |
2231 | (add-log-buffer-file-name-function |
2232 | (lambda () | |
2233 | (let ((file (expand-file-name (cvs-fileinfo->file fi)))) | |
2234 | (if (file-directory-p file) | |
2235 | ;; Be careful to use a directory name, otherwise add-log | |
2236 | ;; starts looking for a ChangeLog file in the | |
2237 | ;; parent dir. | |
2238 | (file-name-as-directory file) | |
2239 | file))))) | |
883e7198 SM |
2240 | (kill-local-variable 'change-log-default-name) |
2241 | (save-excursion (add-change-log-entry-other-window))))) | |
5b467bf4 SM |
2242 | |
2243 | ;; interactive commands to set optional flags | |
2244 | ||
2245 | (defun cvs-mode-set-flags (flag) | |
2246 | "Ask for new setting of cvs-FLAG-flags." | |
2247 | (interactive | |
2248 | (list (completing-read | |
2249 | "Which flag: " | |
883e7198 SM |
2250 | '("cvs" "diff" "update" "status" "log" "tag" ;"rtag" |
2251 | "commit" "remove" "undo" "checkout") | |
5b467bf4 SM |
2252 | nil t))) |
2253 | (let* ((sym (intern (concat "cvs-" flag "-flags")))) | |
2254 | (let ((current-prefix-arg '(16))) | |
2255 | (cvs-flags-query sym (concat flag " flags"))))) | |
2256 | ||
2257 | \f | |
2258 | ;;;; | |
2259 | ;;;; Utilities for the *cvs* buffer | |
2260 | ;;;; | |
2261 | ||
5b467bf4 SM |
2262 | (defun cvs-dir-member-p (fileinfo dir) |
2263 | "Return true if FILEINFO represents a file in directory DIR." | |
2264 | (and (not (eq (cvs-fileinfo->type fileinfo) 'DIRCHANGE)) | |
b15b5618 | 2265 | (cvs-string-prefix-p dir (cvs-fileinfo->dir fileinfo)))) |
5b467bf4 SM |
2266 | |
2267 | (defun cvs-execute-single-file (fi extractor program constant-args) | |
2268 | "Internal function for `cvs-execute-single-file-list'." | |
73eff599 SM |
2269 | (let* ((arg-list (funcall extractor fi)) |
2270 | (inhibit-read-only t)) | |
027b73ac | 2271 | |
5b467bf4 SM |
2272 | ;; Execute the command unless extractor returned t. |
2273 | (when (listp arg-list) | |
2274 | (let* ((args (append constant-args arg-list))) | |
027b73ac | 2275 | |
73eff599 | 2276 | (insert (format "=== %s %s\n\n" |
ad4fed11 | 2277 | program (split-string-and-unquote args))) |
027b73ac | 2278 | |
5b467bf4 | 2279 | ;; FIXME: return the exit status? |
62b84d36 | 2280 | (apply 'process-file program nil t t args) |
5b467bf4 SM |
2281 | (goto-char (point-max)))))) |
2282 | ||
2283 | ;; FIXME: make this run in the background ala cvs-run-process... | |
2284 | (defun cvs-execute-single-file-list (fis extractor program constant-args) | |
2285 | "Run PROGRAM on all elements on FIS. | |
73eff599 SM |
2286 | CONSTANT-ARGS is a list of strings to pass as arguments to PROGRAM. |
2287 | The arguments given to the program will be CONSTANT-ARGS followed by | |
2288 | the list that EXTRACTOR returns. | |
5b467bf4 SM |
2289 | |
2290 | EXTRACTOR will be called once for each file on FIS. It is given | |
2291 | one argument, the cvs-fileinfo. It can return t, which means ignore | |
2292 | this file, or a list of arguments to send to the program." | |
2293 | (dolist (fi fis) | |
2294 | (cvs-execute-single-file fi extractor program constant-args))) | |
2295 | ||
2296 | \f | |
2297 | (defun cvs-revert-if-needed (fis) | |
2298 | (dolist (fileinfo fis) | |
2231c2bc | 2299 | (let* ((file (cvs-fileinfo->full-name fileinfo)) |
5b467bf4 SM |
2300 | (buffer (find-buffer-visiting file))) |
2301 | ;; For a revert to happen the user must be editing the file... | |
2302 | (unless (or (null buffer) | |
77fdc5c3 | 2303 | (memq (cvs-fileinfo->type fileinfo) '(MESSAGE UNKNOWN)) |
5b467bf4 SM |
2304 | ;; FIXME: check whether revert is really needed. |
2305 | ;; `(verify-visited-file-modtime buffer)' doesn't cut it | |
2306 | ;; because it only looks at the time stamp (it ignores | |
2307 | ;; read-write changes) which is not changed by `commit'. | |
2308 | (buffer-modified-p buffer)) | |
2309 | (with-current-buffer buffer | |
a7996e05 SM |
2310 | (ignore-errors |
2311 | (revert-buffer 'ignore-auto 'dont-ask 'preserve-modes) | |
2312 | ;; `preserve-modes' avoids changing the (minor) modes. But we | |
2313 | ;; do want to reset the mode for VC, so we do it explicitly. | |
2314 | (vc-find-file-hook) | |
2315 | (when (eq (cvs-fileinfo->type fileinfo) 'CONFLICT) | |
28e4e2b4 | 2316 | (smerge-start-session)))))))) |
5b467bf4 SM |
2317 | |
2318 | \f | |
2319 | (defun cvs-change-cvsroot (newroot) | |
2320 | "Change the cvsroot." | |
2321 | (interactive "DNew repository: ") | |
2322 | (if (or (file-directory-p (expand-file-name "CVSROOT" newroot)) | |
2323 | (y-or-n-p (concat "Warning: no CVSROOT found inside repository." | |
e1a2960c | 2324 | " Change cvs-cvsroot anyhow? "))) |
5b467bf4 SM |
2325 | (setq cvs-cvsroot newroot))) |
2326 | ||
2327 | ;;;; | |
2328 | ;;;; useful global settings | |
2329 | ;;;; | |
2330 | ||
5b467bf4 SM |
2331 | ;; |
2332 | ;; Hook to allow calling PCL-CVS by visiting the /CVS subdirectory | |
2333 | ;; | |
2334 | ||
6dc7d3d5 | 2335 | ;;;###autoload |
eed914af | 2336 | (defcustom cvs-dired-action 'cvs-quickdir |
6dc7d3d5 SM |
2337 | "The action to be performed when opening a CVS directory. |
2338 | Sensible values are `cvs-examine', `cvs-status' and `cvs-quickdir'." | |
2339 | :group 'pcl-cvs | |
2340 | :type '(choice (const cvs-examine) (const cvs-status) (const cvs-quickdir))) | |
2341 | ||
5b467bf4 SM |
2342 | ;;;###autoload |
2343 | (defcustom cvs-dired-use-hook '(4) | |
2344 | "Whether or not opening a CVS directory should run PCL-CVS. | |
7feaa747 | 2345 | A value of nil means never do it. |
5b467bf4 SM |
2346 | ALWAYS means to always do it unless a prefix argument is given to the |
2347 | command that prompted the opening of the directory. | |
2348 | Anything else means to do it only if the prefix arg is equal to this value." | |
2349 | :group 'pcl-cvs | |
2350 | :type '(choice (const :tag "Never" nil) | |
2351 | (const :tag "Always" always) | |
2352 | (const :tag "Prefix" (4)))) | |
2353 | ||
2354 | ;;;###autoload | |
b15b5618 | 2355 | (progn (defun cvs-dired-noselect (dir) |
5b467bf4 SM |
2356 | "Run `cvs-examine' if DIR is a CVS administrative directory. |
2357 | The exact behavior is determined also by `cvs-dired-use-hook'." | |
2358 | (when (stringp dir) | |
2359 | (setq dir (directory-file-name dir)) | |
2360 | (when (and (string= "CVS" (file-name-nondirectory dir)) | |
2361 | (file-readable-p (expand-file-name "Entries" dir)) | |
2362 | cvs-dired-use-hook | |
2363 | (if (eq cvs-dired-use-hook 'always) | |
2364 | (not current-prefix-arg) | |
2365 | (equal current-prefix-arg cvs-dired-use-hook))) | |
2366 | (save-excursion | |
6dc7d3d5 | 2367 | (funcall cvs-dired-action (file-name-directory dir) t t)))))) |
5b467bf4 SM |
2368 | |
2369 | ;; | |
2370 | ;; hook into VC | |
2371 | ;; | |
2372 | ||
d15c2aaa SM |
2373 | (add-hook 'vc-post-command-functions 'cvs-vc-command-advice) |
2374 | ||
b6e9189c | 2375 | (defun cvs-vc-command-advice (command files flags) |
d15c2aaa | 2376 | (when (and (equal command "cvs") |
db750be7 SM |
2377 | (progn |
2378 | (while (and (stringp (car flags)) | |
2379 | (string-match "\\`-" (car flags))) | |
2380 | (pop flags)) | |
2381 | ;; don't parse output we don't understand. | |
61454605 SM |
2382 | (member (car flags) cvs-parse-known-commands)) |
2383 | ;; Don't parse "update -p" output. | |
2384 | (not (and (member (car flags) '("update" "checkout")) | |
2385 | (let ((found-p nil)) | |
2386 | (dolist (flag flags found-p) | |
2387 | (if (equal flag "-p") (setq found-p t))))))) | |
498ecdde | 2388 | (save-current-buffer |
d15c2aaa SM |
2389 | (let ((buffer (current-buffer)) |
2390 | (dir default-directory) | |
5b467bf4 SM |
2391 | (cvs-from-vc t)) |
2392 | (dolist (cvs-buf (buffer-list)) | |
2393 | (set-buffer cvs-buf) | |
2394 | ;; look for a corresponding pcl-cvs buffer | |
2395 | (when (and (eq major-mode 'cvs-mode) | |
2396 | (cvs-string-prefix-p default-directory dir)) | |
2397 | (let ((subdir (substring dir (length default-directory)))) | |
2398 | (set-buffer buffer) | |
2399 | (set (make-local-variable 'cvs-buffer) cvs-buf) | |
498ecdde SM |
2400 | ;; `cvs -q add file' produces no useful output :-( |
2401 | (when (and (equal (car flags) "add") | |
2402 | (goto-char (point-min)) | |
2403 | (looking-at ".*to add this file permanently\n\\'")) | |
dae2bd56 | 2404 | (dolist (file (if (listp files) files (list files))) |
b6e9189c SM |
2405 | (insert "cvs add: scheduling file `" |
2406 | (file-name-nondirectory file) | |
2407 | "' for addition\n"))) | |
5b467bf4 SM |
2408 | ;; VC never (?) does `cvs -n update' so dcd=nil |
2409 | ;; should probably always be the right choice. | |
2410 | (cvs-parse-process nil subdir)))))))) | |
2411 | ||
2412 | ;; | |
2413 | ;; Hook into write-buffer | |
2414 | ;; | |
2415 | ||
2416 | (defun cvs-mark-buffer-changed () | |
2417 | (let* ((file (expand-file-name buffer-file-name)) | |
2418 | (version (and (fboundp 'vc-backend) | |
2419 | (eq (vc-backend file) 'CVS) | |
ac3f4c6f | 2420 | (vc-working-revision file)))) |
5b467bf4 SM |
2421 | (when version |
2422 | (save-excursion | |
2423 | (dolist (cvs-buf (buffer-list)) | |
2424 | (set-buffer cvs-buf) | |
2425 | ;; look for a corresponding pcl-cvs buffer | |
2426 | (when (and (eq major-mode 'cvs-mode) | |
2427 | (cvs-string-prefix-p default-directory file)) | |
2428 | (let* ((file (substring file (length default-directory))) | |
2429 | (fi (cvs-create-fileinfo | |
2430 | (if (string= "0" version) | |
2431 | 'ADDED 'MODIFIED) | |
2432 | (or (file-name-directory file) "") | |
2433 | (file-name-nondirectory file) | |
2434 | "cvs-mark-buffer-changed"))) | |
2435 | (cvs-addto-collection cvs-cookies fi)))))))) | |
2436 | ||
2437 | (add-hook 'after-save-hook 'cvs-mark-buffer-changed) | |
2438 | ||
5b467bf4 SM |
2439 | \f |
2440 | (provide 'pcvs) | |
2441 | ||
38400c2a | 2442 | ;; arch-tag: 8e3a7494-0453-4389-9ab3-a557ce9fab61 |
5b467bf4 | 2443 | ;;; pcvs.el ends here |