comparison lisp/pcvs-info.el @ 88155:d7ddb3e565de

sync with trunk
author Henrik Enberg <henrik.enberg@telia.com>
date Mon, 16 Jan 2006 00:03:54 +0000
parents e88404e8f2cf
children
comparison
equal deleted inserted replaced
88154:8ce476d3ba36 88155:d7ddb3e565de
1 ;;; pcvs-info.el --- internal representation of a fileinfo entry 1 ;;; pcvs-info.el --- internal representation of a fileinfo entry
2 2
3 ;; Copyright (C) 1991, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc. 3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 ;; 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 5
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu> 6 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
6 ;; Keywords: pcl-cvs 7 ;; Keywords: pcl-cvs
7 ;; Revision: $Id: pcvs-info.el,v 1.14 2003/01/14 21:53:39 monnier Exp $
8 8
9 ;; This file is part of GNU Emacs. 9 ;; This file is part of GNU Emacs.
10 10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify 11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by 12 ;; it under the terms of the GNU General Public License as published by
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details. 19 ;; GNU General Public License for more details.
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02111-1307, USA. 24 ;; Boston, MA 02110-1301, USA.
25 25
26 ;;; Commentary: 26 ;;; Commentary:
27 27
28 ;; The cvs-fileinfo data structure: 28 ;; The cvs-fileinfo data structure:
29 ;; 29 ;;
39 39
40 ;;;; 40 ;;;;
41 ;;;; config variables 41 ;;;; config variables
42 ;;;; 42 ;;;;
43 43
44 (defcustom cvs-display-full-path t 44 (defcustom cvs-display-full-name t
45 "*Specifies how the filenames should look like in the listing. 45 "*Specifies how the filenames should be displayed in the listing.
46 If t, their full path name will be displayed, else only the filename." 46 If non-nil, their full filename name will be displayed, else only the
47 non-directory part."
47 :group 'pcl-cvs 48 :group 'pcl-cvs
48 :type '(boolean)) 49 :type '(boolean))
50 (define-obsolete-variable-alias 'cvs-display-full-path 'cvs-display-full-name)
49 51
50 (defcustom cvs-allow-dir-commit nil 52 (defcustom cvs-allow-dir-commit nil
51 "*Allow `cvs-mode-commit' on directories. 53 "*Allow `cvs-mode-commit' on directories.
52 If you commit without any marked file and with the cursor positioned 54 If you commit without any marked file and with the cursor positioned
53 on a directory entry, cvs would commit the whole directory. This seems 55 on a directory entry, cvs would commit the whole directory. This seems
57 59
58 ;;;; 60 ;;;;
59 ;;;; Faces for fontification 61 ;;;; Faces for fontification
60 ;;;; 62 ;;;;
61 63
62 (defface cvs-header-face 64 (defface cvs-header
63 '((((class color) (background dark)) 65 '((((class color) (background dark))
64 (:foreground "lightyellow" :weight bold)) 66 (:foreground "lightyellow" :weight bold))
65 (((class color) (background light)) 67 (((class color) (background light))
66 (:foreground "blue4" :weight bold)) 68 (:foreground "blue4" :weight bold))
67 (t (:weight bold))) 69 (t (:weight bold)))
68 "PCL-CVS face used to highlight directory changes." 70 "PCL-CVS face used to highlight directory changes."
69 :group 'pcl-cvs) 71 :group 'pcl-cvs)
70 72 ;; backward-compatibility alias
71 (defface cvs-filename-face 73 (put 'cvs-header-face 'face-alias 'cvs-header)
74
75 (defface cvs-filename
72 '((((class color) (background dark)) 76 '((((class color) (background dark))
73 (:foreground "lightblue")) 77 (:foreground "lightblue"))
74 (((class color) (background light)) 78 (((class color) (background light))
75 (:foreground "blue4")) 79 (:foreground "blue4"))
76 (t ())) 80 (t ()))
77 "PCL-CVS face used to highlight file names." 81 "PCL-CVS face used to highlight file names."
78 :group 'pcl-cvs) 82 :group 'pcl-cvs)
79 83 ;; backward-compatibility alias
80 (defface cvs-unknown-face 84 (put 'cvs-filename-face 'face-alias 'cvs-filename)
85
86 (defface cvs-unknown
81 '((((class color) (background dark)) 87 '((((class color) (background dark))
82 (:foreground "red")) 88 (:foreground "red"))
83 (((class color) (background light)) 89 (((class color) (background light))
84 (:foreground "red")) 90 (:foreground "red"))
85 (t (:slant italic))) 91 (t (:slant italic)))
86 "PCL-CVS face used to highlight unknown file status." 92 "PCL-CVS face used to highlight unknown file status."
87 :group 'pcl-cvs) 93 :group 'pcl-cvs)
88 94 ;; backward-compatibility alias
89 (defface cvs-handled-face 95 (put 'cvs-unknown-face 'face-alias 'cvs-unknown)
96
97 (defface cvs-handled
90 '((((class color) (background dark)) 98 '((((class color) (background dark))
91 (:foreground "pink")) 99 (:foreground "pink"))
92 (((class color) (background light)) 100 (((class color) (background light))
93 (:foreground "pink")) 101 (:foreground "pink"))
94 (t ())) 102 (t ()))
95 "PCL-CVS face used to highlight handled file status." 103 "PCL-CVS face used to highlight handled file status."
96 :group 'pcl-cvs) 104 :group 'pcl-cvs)
97 105 ;; backward-compatibility alias
98 (defface cvs-need-action-face 106 (put 'cvs-handled-face 'face-alias 'cvs-handled)
107
108 (defface cvs-need-action
99 '((((class color) (background dark)) 109 '((((class color) (background dark))
100 (:foreground "orange")) 110 (:foreground "orange"))
101 (((class color) (background light)) 111 (((class color) (background light))
102 (:foreground "orange")) 112 (:foreground "orange"))
103 (t (:slant italic))) 113 (t (:slant italic)))
104 "PCL-CVS face used to highlight status of files needing action." 114 "PCL-CVS face used to highlight status of files needing action."
105 :group 'pcl-cvs) 115 :group 'pcl-cvs)
106 116 ;; backward-compatibility alias
107 (defface cvs-marked-face 117 (put 'cvs-need-action-face 'face-alias 'cvs-need-action)
108 '((((class color) (background dark)) 118
119 (defface cvs-marked
120 '((((min-colors 88) (class color) (background dark))
121 (:foreground "green1" :weight bold))
122 (((class color) (background dark))
109 (:foreground "green" :weight bold)) 123 (:foreground "green" :weight bold))
110 (((class color) (background light)) 124 (((class color) (background light))
111 (:foreground "green3" :weight bold)) 125 (:foreground "green3" :weight bold))
112 (t (:weight bold))) 126 (t (:weight bold)))
113 "PCL-CVS face used to highlight marked file indicator." 127 "PCL-CVS face used to highlight marked file indicator."
114 :group 'pcl-cvs) 128 :group 'pcl-cvs)
115 129 ;; backward-compatibility alias
116 (defface cvs-msg-face 130 (put 'cvs-marked-face 'face-alias 'cvs-marked)
131
132 (defface cvs-msg
117 '((t (:slant italic))) 133 '((t (:slant italic)))
118 "PCL-CVS face used to highlight CVS messages." 134 "PCL-CVS face used to highlight CVS messages."
119 :group 'pcl-cvs) 135 :group 'pcl-cvs)
120 136 ;; backward-compatibility alias
121 (defvar cvs-fi-up-to-date-face 'cvs-handled-face) 137 (put 'cvs-msg-face 'face-alias 'cvs-msg)
122 (defvar cvs-fi-unknown-face 'cvs-unknown-face) 138
139 (defvar cvs-fi-up-to-date-face 'cvs-handled)
140 (defvar cvs-fi-unknown-face 'cvs-unknown)
123 (defvar cvs-fi-conflict-face 'font-lock-warning-face) 141 (defvar cvs-fi-conflict-face 'font-lock-warning-face)
124 142
125 ;; There is normally no need to alter the following variable, but if 143 ;; There is normally no need to alter the following variable, but if
126 ;; your site has installed CVS in a non-standard way you might have 144 ;; your site has installed CVS in a non-standard way you might have
127 ;; to change it. 145 ;; to change it.
128 146
129 (defvar cvs-bakprefix ".#" 147 (defvar cvs-bakprefix ".#"
130 "The prefix that CVS prepends to files when rcsmerge'ing.") 148 "The prefix that CVS prepends to files when rcsmerge'ing.")
131 149
132 (easy-mmode-defmap cvs-status-map 150 (easy-mmode-defmap cvs-status-map
133 '(([(mouse-2)] . cvs-mouse-toggle-mark)) 151 '(([(mouse-2)] . cvs-mode-toggle-mark))
134 "Local keymap for text properties of status") 152 "Local keymap for text properties of status")
135 153
136 ;; Constructor: 154 ;; Constructor:
137 155
138 (defstruct (cvs-fileinfo 156 (defstruct (cvs-fileinfo
161 ;;mod-time ;; Not used. 179 ;;mod-time ;; Not used.
162 180
163 ;; In addition to the above, the following values can be extracted: 181 ;; In addition to the above, the following values can be extracted:
164 182
165 ;; handled ;; t if this file doesn't require further action. 183 ;; handled ;; t if this file doesn't require further action.
166 ;; full-path ;; The complete relative filename. 184 ;; full-name ;; The complete relative filename.
167 ;; pp-name ;; The printed file name 185 ;; pp-name ;; The printed file name
168 ;; backup-file;; For MERGED and CONFLICT files after a \"cvs update\", 186 ;; backup-file;; For MERGED and CONFLICT files after a \"cvs update\",
169 ;; this is a full path to the backup file where the 187 ;; this is a full path to the backup file where the
170 ;; untouched version resides. 188 ;; untouched version resides.
171 189
197 (defun cvs-create-fileinfo (type dir file msg &rest keys) 215 (defun cvs-create-fileinfo (type dir file msg &rest keys)
198 (cvs-check-fileinfo (apply #'-cvs-create-fileinfo type dir file msg keys))) 216 (cvs-check-fileinfo (apply #'-cvs-create-fileinfo type dir file msg keys)))
199 217
200 ;; Fake selectors: 218 ;; Fake selectors:
201 219
202 (defun cvs-fileinfo->full-path (fileinfo) 220 (defun cvs-fileinfo->full-name (fileinfo)
203 "Return the full path for the file that is described in FILEINFO." 221 "Return the full path for the file that is described in FILEINFO."
204 (let ((dir (cvs-fileinfo->dir fileinfo))) 222 (let ((dir (cvs-fileinfo->dir fileinfo)))
205 (if (eq (cvs-fileinfo->type fileinfo) 'DIRCHANGE) 223 (if (eq (cvs-fileinfo->type fileinfo) 'DIRCHANGE)
206 (if (string= dir "") "." (directory-file-name dir)) 224 (if (string= dir "") "." (directory-file-name dir))
207 ;; Here, I use `concat' rather than `expand-file-name' because I want 225 ;; Here, I use `concat' rather than `expand-file-name' because I want
208 ;; the resulting path to stay relative if `dir' is relative. 226 ;; the resulting path to stay relative if `dir' is relative.
209 (concat dir (cvs-fileinfo->file fileinfo))))) 227 (concat dir (cvs-fileinfo->file fileinfo)))))
228 (define-obsolete-function-alias 'cvs-fileinfo->full-path 'cvs-fileinfo->full-name)
210 229
211 (defun cvs-fileinfo->pp-name (fi) 230 (defun cvs-fileinfo->pp-name (fi)
212 "Return the filename of FI as it should be displayed." 231 "Return the filename of FI as it should be displayed."
213 (if cvs-display-full-path 232 (if cvs-display-full-name
214 (cvs-fileinfo->full-path fi) 233 (cvs-fileinfo->full-name fi)
215 (cvs-fileinfo->file fi))) 234 (cvs-fileinfo->file fi)))
216 235
217 (defun cvs-fileinfo->backup-file (fileinfo) 236 (defun cvs-fileinfo->backup-file (fileinfo)
218 "Construct the file name of the backup file for FILEINFO." 237 "Construct the file name of the backup file for FILEINFO."
219 (let* ((dir (cvs-fileinfo->dir fileinfo)) 238 (let* ((dir (cvs-fileinfo->dir fileinfo))
220 (file (cvs-fileinfo->file fileinfo)) 239 (file (cvs-fileinfo->file fileinfo))
221 (default-directory (file-name-as-directory (expand-file-name dir))) 240 (default-directory (file-name-as-directory (expand-file-name dir)))
222 (files (directory-files "." nil 241 (files (directory-files "." nil
223 (concat "^" (regexp-quote cvs-bakprefix) 242 (concat "\\`" (regexp-quote cvs-bakprefix)
224 (regexp-quote file) "\\."))) 243 (regexp-quote file) "\\(\\.[0-9]+\\.[0-9]+\\)+\\'")))
225 bf) 244 bf)
226 (dolist (f files bf) 245 (dolist (f files)
227 (when (and (file-readable-p f) 246 (when (and (file-readable-p f)
228 (or (null bf) (file-newer-than-file-p f bf))) 247 (or (null bf) (file-newer-than-file-p f bf)))
229 (setq bf (concat dir f)))))) 248 (setq bf f)))
249 (concat dir bf)))
230 250
231 ;; (defun cvs-fileinfo->handled (fileinfo) 251 ;; (defun cvs-fileinfo->handled (fileinfo)
232 ;; "Tell if this requires further action" 252 ;; "Tell if this requires further action"
233 ;; (memq (cvs-fileinfo->type fileinfo) '(UP-TO-DATE DEAD))) 253 ;; (memq (cvs-fileinfo->type fileinfo) '(UP-TO-DATE DEAD)))
234 254
272 ;;;; 292 ;;;;
273 ;;;; State table to indicate what you can do when. 293 ;;;; State table to indicate what you can do when.
274 ;;;; 294 ;;;;
275 295
276 (defconst cvs-states 296 (defconst cvs-states
277 `((NEED-UPDATE update diff) 297 `((NEED-UPDATE update diff ignore)
278 (UP-TO-DATE update nil remove diff safe-rm revert) 298 (UP-TO-DATE update nil remove diff safe-rm revert)
279 (MODIFIED update commit undo remove diff merge diff-base) 299 (MODIFIED update commit undo remove diff merge diff-base)
280 (ADDED update commit remove) 300 (ADDED update commit remove)
281 (MISSING remove undo update safe-rm revert) 301 (MISSING remove undo update safe-rm revert)
282 (REMOVED commit add undo safe-rm) 302 (REMOVED commit add undo safe-rm)
323 (let ((type (cvs-fileinfo->type fileinfo)) 343 (let ((type (cvs-fileinfo->type fileinfo))
324 (subtype (cvs-fileinfo->subtype fileinfo))) 344 (subtype (cvs-fileinfo->subtype fileinfo)))
325 (insert 345 (insert
326 (case type 346 (case type
327 (DIRCHANGE (concat "In directory " 347 (DIRCHANGE (concat "In directory "
328 (cvs-add-face (cvs-fileinfo->full-path fileinfo) 348 (cvs-add-face (cvs-fileinfo->full-name fileinfo)
329 'cvs-header-face t 349 'cvs-header t 'cvs-goal-column t)
330 'cvs-goal-column t)
331 ":")) 350 ":"))
332 (MESSAGE 351 (MESSAGE
333 (cvs-add-face (format "Message: %s" (cvs-fileinfo->full-log fileinfo)) 352 (cvs-add-face (format "Message: %s" (cvs-fileinfo->full-log fileinfo))
334 'cvs-msg-face)) 353 'cvs-msg))
335 (t 354 (t
336 (let* ((status (if (cvs-fileinfo->marked fileinfo) 355 (let* ((status (if (cvs-fileinfo->marked fileinfo)
337 (cvs-add-face "*" 'cvs-marked-face) 356 (cvs-add-face "*" 'cvs-marked)
338 " ")) 357 " "))
339 (file (cvs-add-face (cvs-fileinfo->pp-name fileinfo) 358 (file (cvs-add-face (cvs-fileinfo->pp-name fileinfo)
340 'cvs-filename-face t 359 'cvs-filename t 'cvs-goal-column t))
341 'cvs-goal-column t))
342 (base (or (cvs-fileinfo->base-rev fileinfo) "")) 360 (base (or (cvs-fileinfo->base-rev fileinfo) ""))
343 (head (cvs-fileinfo->head-rev fileinfo)) 361 (head (cvs-fileinfo->head-rev fileinfo))
344 (type 362 (type
345 (let ((str (case type 363 (let ((str (case type
346 ;;(MOD-CONFLICT "Not Removed") 364 ;;(MOD-CONFLICT "Not Removed")
349 (face (let ((sym (intern 367 (face (let ((sym (intern
350 (concat "cvs-fi-" 368 (concat "cvs-fi-"
351 (downcase (symbol-name type)) 369 (downcase (symbol-name type))
352 "-face")))) 370 "-face"))))
353 (or (and (boundp sym) (symbol-value sym)) 371 (or (and (boundp sym) (symbol-value sym))
354 'cvs-need-action-face)))) 372 'cvs-need-action))))
355 (cvs-add-face str face cvs-status-map))) 373 (cvs-add-face str face cvs-status-map)))
356 (side (or 374 (side (or
357 ;; maybe a subtype 375 ;; maybe a subtype
358 (when subtype (downcase (symbol-name subtype))) 376 (when subtype (downcase (symbol-name subtype)))
359 ;; or the head-rev 377 ;; or the head-rev
469 (forward-line 1)))) 487 (forward-line 1))))
470 fis)) 488 fis))
471 489
472 (provide 'pcvs-info) 490 (provide 'pcvs-info)
473 491
492 ;; arch-tag: d85dde07-bdc2-400a-882f-92f398c7b0ba
474 ;;; pcvs-info.el ends here 493 ;;; pcvs-info.el ends here