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