comparison lisp/pcvs.el @ 30569:f7a0912532da

* pcvs.el (cvs-do-commit): Use `buffer-substring-no-properties' instead of `buffer-string'. (require 'cl): Always, not just when compiling. `ignore-errors' in `interactive', `list*', `defun*' &c make this necessary.
author Sam Steingold <sds@gnu.org>
date Thu, 03 Aug 2000 18:11:47 +0000
parents ce3a0229bee7
children a019ed819488
comparison
equal deleted inserted replaced
30568:904cda56fa16 30569:f7a0912532da
12 ;; (Greg Klanderman) greg@alphatech.com 12 ;; (Greg Klanderman) greg@alphatech.com
13 ;; (Jari Aalto+mail.emacs) jari.aalto@poboxes.com 13 ;; (Jari Aalto+mail.emacs) jari.aalto@poboxes.com
14 ;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu 14 ;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu
15 ;; Keywords: CVS, version control, release management 15 ;; Keywords: CVS, version control, release management
16 ;; Version: $Name: $ 16 ;; Version: $Name: $
17 ;; Revision: $Id: pcvs.el,v 1.3 2000/05/10 22:28:36 monnier Exp $ 17 ;; Revision: $Id: pcvs.el,v 1.4 2000/06/12 04:48:35 monnier Exp $
18 18
19 ;; This file is part of GNU Emacs. 19 ;; This file is part of GNU Emacs.
20 20
21 ;; GNU Emacs is free software; you can redistribute it and/or modify 21 ;; GNU Emacs is free software; you can redistribute it and/or modify
22 ;; it under the terms of the GNU General Public License as published by 22 ;; it under the terms of the GNU General Public License as published by
54 ;; it's not even worth looking at it. 54 ;; it's not even worth looking at it.
55 55
56 ;;; Todo: 56 ;;; Todo:
57 57
58 ;; ******** FIX THE DOCUMENTATION ********* 58 ;; ******** FIX THE DOCUMENTATION *********
59 ;; 59 ;;
60 ;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine 60 ;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine
61 ;; - add toolbar entries 61 ;; - add toolbar entries
62 ;; - marking 62 ;; - marking
63 ;; marking directories should jump to just after the dir. 63 ;; marking directories should jump to just after the dir.
64 ;; allow (un)marking directories at a time with the mouse. 64 ;; allow (un)marking directories at a time with the mouse.
107 ;; instance. 107 ;; instance.
108 ;; - add message-levels so that we can hide some levels of messages 108 ;; - add message-levels so that we can hide some levels of messages
109 109
110 ;;; Code: 110 ;;; Code:
111 111
112 (eval-when-compile (require 'cl)) 112 (require 'cl)
113 (require 'ewoc) ;Ewoc was once cookie 113 (require 'ewoc) ;Ewoc was once cookie
114 (require 'pcvs-defs) 114 (require 'pcvs-defs)
115 (require 'pcvs-util) 115 (require 'pcvs-util)
116 (require 'pcvs-parse) 116 (require 'pcvs-parse)
117 (require 'pcvs-info) 117 (require 'pcvs-info)
129 ;;;; Dynamically scoped variables 129 ;;;; Dynamically scoped variables
130 ;;;; 130 ;;;;
131 131
132 (defvar cvs-from-vc nil "Bound to t inside VC advice.") 132 (defvar cvs-from-vc nil "Bound to t inside VC advice.")
133 133
134 ;;;; 134 ;;;;
135 ;;;; flags variables 135 ;;;; flags variables
136 ;;;; 136 ;;;;
137 137
138 (defun cvs-defaults (&rest defs) 138 (defun cvs-defaults (&rest defs)
139 (let ((defs (cvs-first defs cvs-shared-start))) 139 (let ((defs (cvs-first defs cvs-shared-start)))
140 (append defs 140 (append defs
141 (make-list (- cvs-shared-start (length defs)) (first defs)) 141 (make-list (- cvs-shared-start (length defs)) (first defs))
193 193
194 (defvar cvs-mode-line-process nil 194 (defvar cvs-mode-line-process nil
195 "Mode-line control for displaying info on cvs process status.") 195 "Mode-line control for displaying info on cvs process status.")
196 196
197 197
198 ;;;; 198 ;;;;
199 ;;;; Query-Type-Descriptor for Tags 199 ;;;; Query-Type-Descriptor for Tags
200 ;;;; 200 ;;;;
201 201
202 (autoload 'cvs-status-get-tags "cvs-status") 202 (autoload 'cvs-status-get-tags "cvs-status")
203 (defun cvs-tags-list () 203 (defun cvs-tags-list ()
204 "Return a list of acceptable tags, ready for completions." 204 "Return a list of acceptable tags, ready for completions."
205 (assert (cvs-buffer-p)) 205 (assert (cvs-buffer-p))
220 220
221 (defvar cvs-tag-history nil) 221 (defvar cvs-tag-history nil)
222 (defconst cvs-qtypedesc-tag 222 (defconst cvs-qtypedesc-tag
223 (cvs-qtypedesc-create 'identity 'identity 'cvs-tags-list 'cvs-tag-history)) 223 (cvs-qtypedesc-create 'identity 'identity 'cvs-tags-list 'cvs-tag-history))
224 224
225 ;;;; 225 ;;;;
226 226
227 (defun cvs-mode! (&optional -cvs-mode!-fun -cvs-mode!-noerror) 227 (defun cvs-mode! (&optional -cvs-mode!-fun -cvs-mode!-noerror)
228 "Switch to the *cvs* buffer. 228 "Switch to the *cvs* buffer.
229 If -CVS-MODE!-FUN is provided, it is executed *cvs* being the current buffer 229 If -CVS-MODE!-FUN is provided, it is executed *cvs* being the current buffer
230 and with its window selected. Else, the *cvs* buffer is simply selected. 230 and with its window selected. Else, the *cvs* buffer is simply selected.
256 (set-buffer cvs-mode!-buf) 256 (set-buffer cvs-mode!-buf)
257 (when (and cvs-mode!-nwin (eq cvs-mode!-nwin (selected-window))) 257 (when (and cvs-mode!-nwin (eq cvs-mode!-nwin (selected-window)))
258 ;; the selected window has not been changed by FUN 258 ;; the selected window has not been changed by FUN
259 (select-window cvs-mode!-owin))))))) 259 (select-window cvs-mode!-owin)))))))
260 260
261 ;;;; 261 ;;;;
262 ;;;; Prefixes 262 ;;;; Prefixes
263 ;;;; 263 ;;;;
264 264
265 (defvar cvs-branches (list cvs-vendor-branch "HEAD" "HEAD")) 265 (defvar cvs-branches (list cvs-vendor-branch "HEAD" "HEAD"))
266 (cvs-prefix-define cvs-branch-prefix 266 (cvs-prefix-define cvs-branch-prefix
267 "Current selected branch." 267 "Current selected branch."
268 "version" 268 "version"
311 the primay since reading the primary can deactivate it." 311 the primay since reading the primary can deactivate it."
312 (let ((branch (and (cvs-prefix-get 'cvs-branch-prefix 'read-only) 312 (let ((branch (and (cvs-prefix-get 'cvs-branch-prefix 'read-only)
313 (cvs-prefix-get 'cvs-secondary-branch-prefix)))) 313 (cvs-prefix-get 'cvs-secondary-branch-prefix))))
314 (if branch (cons (concat (or arg "-r") branch) flags) flags))) 314 (if branch (cons (concat (or arg "-r") branch) flags) flags)))
315 315
316 ;;;; 316 ;;;;
317 317
318 (define-minor-mode 318 (define-minor-mode
319 cvs-minor-mode 319 cvs-minor-mode
320 " 320 "
321 This mode is used for buffers related to a main *cvs* buffer. 321 This mode is used for buffers related to a main *cvs* buffer.
347 cvs-temp-buffer) 347 cvs-temp-buffer)
348 (t 348 (t
349 (set (make-local-variable 'cvs-temp-buffer) 349 (set (make-local-variable 'cvs-temp-buffer)
350 (cvs-get-buffer-create 350 (cvs-get-buffer-create
351 (eval cvs-temp-buffer-name) 'noreuse)))))) 351 (eval cvs-temp-buffer-name) 'noreuse))))))
352 352
353 ;; handle the potential pre-existing process 353 ;; handle the potential pre-existing process
354 (let ((proc (get-buffer-process buf))) 354 (let ((proc (get-buffer-process buf)))
355 (when (and (not normal) (processp proc) 355 (when (and (not normal) (processp proc)
356 (memq (process-status proc) '(run stop))) 356 (memq (process-status proc) '(run stop)))
357 (error "Can not run two cvs processes simultaneously"))) 357 (error "Can not run two cvs processes simultaneously")))
474 (assert (cvs-buffer-p cvs-buffer)) 474 (assert (cvs-buffer-p cvs-buffer))
475 (save-current-buffer 475 (save-current-buffer
476 (let ((procbuf (current-buffer)) 476 (let ((procbuf (current-buffer))
477 (cvsbuf cvs-buffer) 477 (cvsbuf cvs-buffer)
478 (single-dir (or single-dir (eq cvs-execute-single-dir t)))) 478 (single-dir (or single-dir (eq cvs-execute-single-dir t))))
479 479
480 (set-buffer procbuf) 480 (set-buffer procbuf)
481 (goto-char (point-max)) 481 (goto-char (point-max))
482 (unless (bolp) (let ((inhibit-read-only t)) (insert "\n"))) 482 (unless (bolp) (let ((inhibit-read-only t)) (insert "\n")))
483 ;; find the set of files we'll process in this round 483 ;; find the set of files we'll process in this round
484 (let* ((dir+files+rest 484 (let* ((dir+files+rest
497 ((not (and fis (string= dir (cvs-fileinfo->dir fi)))) 497 ((not (and fis (string= dir (cvs-fileinfo->dir fi))))
498 (list dir files fis)))))) 498 (list dir files fis))))))
499 (dir (first dir+files+rest)) 499 (dir (first dir+files+rest))
500 (files (second dir+files+rest)) 500 (files (second dir+files+rest))
501 (rest (third dir+files+rest))) 501 (rest (third dir+files+rest)))
502 502
503 ;; setup the (current) process buffer 503 ;; setup the (current) process buffer
504 (set (make-local-variable 'cvs-postprocess) 504 (set (make-local-variable 'cvs-postprocess)
505 (if (null rest) 505 (if (null rest)
506 ;; this is the last invocation 506 ;; this is the last invocation
507 postprocess 507 postprocess
529 (apply 'start-process "cvs" procbuf cvs-program args)))) 529 (apply 'start-process "cvs" procbuf cvs-program args))))
530 (set-process-sentinel process 'cvs-sentinel) 530 (set-process-sentinel process 'cvs-sentinel)
531 (set-process-filter process 'cvs-update-filter) 531 (set-process-filter process 'cvs-update-filter)
532 (set-marker (process-mark process) (point-max)) 532 (set-marker (process-mark process) (point-max))
533 (ignore-errors (process-send-eof process)) ;close its stdin to avoid hangs 533 (ignore-errors (process-send-eof process)) ;close its stdin to avoid hangs
534 534
535 ;; now finish setting up the cvs-buffer 535 ;; now finish setting up the cvs-buffer
536 (set-buffer cvsbuf) 536 (set-buffer cvsbuf)
537 (setq cvs-mode-line-process (symbol-name (process-status process))) 537 (setq cvs-mode-line-process (symbol-name (process-status process)))
538 (force-mode-line-update))))) 538 (force-mode-line-update)))))
539 539
780 ;; handled also? 780 ;; handled also?
781 (UP-TO-DATE (not rm-handled)) 781 (UP-TO-DATE (not rm-handled))
782 ;; keep the rest 782 ;; keep the rest
783 (t (not (run-hook-with-args-until-success 783 (t (not (run-hook-with-args-until-success
784 'cvs-cleanup-functions fi)))))) 784 'cvs-cleanup-functions fi))))))
785 785
786 ;; mark dirs for removal 786 ;; mark dirs for removal
787 (when (and keep rm-dirs 787 (when (and keep rm-dirs
788 (eq (cvs-fileinfo->type last-fi) 'DIRCHANGE) 788 (eq (cvs-fileinfo->type last-fi) 'DIRCHANGE)
789 (not (when first-dir (setq first-dir nil) t)) 789 (not (when first-dir (setq first-dir nil) t))
790 (or (eq rm-dirs 'all) 790 (or (eq rm-dirs 'all)
850 (cvs-cmd-do "checkout" (or dir default-directory) 850 (cvs-cmd-do "checkout" (or dir default-directory)
851 (append flags modules) nil 'new 851 (append flags modules) nil 'new
852 :noexist t)) 852 :noexist t))
853 853
854 854
855 ;;;; 855 ;;;;
856 ;;;; The code for running a "cvs update" and friends in various ways. 856 ;;;; The code for running a "cvs update" and friends in various ways.
857 ;;;; 857 ;;;;
858 858
859 (defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE) 859 (defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE)
860 (&optional ignore-auto noconfirm) 860 (&optional ignore-auto noconfirm)
861 "Rerun cvs-examine on the current directory with the defauls flags." 861 "Rerun cvs-examine on the current directory with the defauls flags."
862 (interactive) 862 (interactive)
979 (ewoc-enter-last 979 (ewoc-enter-last
980 cvs-cookies 980 cvs-cookies
981 (cvs-create-fileinfo 981 (cvs-create-fileinfo
982 'MESSAGE "" " " 982 'MESSAGE "" " "
983 (concat msg 983 (concat msg
984 (substitute-command-keys 984 (substitute-command-keys
985 "\n\t(type \\[cvs-mode-delete-lock] to delete it)")) 985 "\n\t(type \\[cvs-mode-delete-lock] to delete it)"))
986 :subtype 'TEMP)) 986 :subtype 'TEMP))
987 (pop-to-buffer (current-buffer)) 987 (pop-to-buffer (current-buffer))
988 (goto-char (point-max)) 988 (goto-char (point-max))
989 (beep))))))))) 989 (beep)))))))))
1091 "Go to the next line. 1091 "Go to the next line.
1092 If a prefix argument is given, move by that many lines." 1092 If a prefix argument is given, move by that many lines."
1093 (interactive "p") 1093 (interactive "p")
1094 (ewoc-goto-next cvs-cookies (point) arg)) 1094 (ewoc-goto-next cvs-cookies (point) arg))
1095 1095
1096 ;;;; 1096 ;;;;
1097 ;;;; Mark handling 1097 ;;;; Mark handling
1098 ;;;; 1098 ;;;;
1099 1099
1100 (defun-cvs-mode cvs-mode-mark (&optional arg) 1100 (defun-cvs-mode cvs-mode-mark (&optional arg)
1101 "Mark the fileinfo on the current line. 1101 "Mark the fileinfo on the current line.
1102 If the fileinfo is a directory, all the contents of that directory are 1102 If the fileinfo is a directory, all the contents of that directory are
1103 marked instead. A directory can never be marked." 1103 marked instead. A directory can never be marked."
1178 (cvs-qtypedesc-create 1178 (cvs-qtypedesc-create
1179 (lambda (str) (cdr (assoc str cvs-ignore-marks-alternatives))) 1179 (lambda (str) (cdr (assoc str cvs-ignore-marks-alternatives)))
1180 (lambda (obj) (caar (member* obj cvs-ignore-marks-alternatives :key 'cdr))) 1180 (lambda (obj) (caar (member* obj cvs-ignore-marks-alternatives :key 'cdr)))
1181 (lambda () cvs-ignore-marks-alternatives) 1181 (lambda () cvs-ignore-marks-alternatives)
1182 nil t)) 1182 nil t))
1183 1183
1184 (defun-cvs-mode cvs-mode-toggle-marks (arg) 1184 (defun-cvs-mode cvs-mode-toggle-marks (arg)
1185 "Toggle whether the next CVS command uses marks. 1185 "Toggle whether the next CVS command uses marks.
1186 See `cvs-prefix-set' for further description of the behavior. 1186 See `cvs-prefix-set' for further description of the behavior.
1187 \\[universal-argument] 1 selects `force-marks', 1187 \\[universal-argument] 1 selects `force-marks',
1188 \\[universal-argument] 2 selects `ignore-marks', 1188 \\[universal-argument] 2 selects `ignore-marks',
1189 \\[universal-argument] 3 selects `toggle-marks'." 1189 \\[universal-argument] 3 selects `toggle-marks'."
1190 (interactive "P") 1190 (interactive "P")
1191 (cvs-prefix-set 'cvs-ignore-marks-modif arg)) 1191 (cvs-prefix-set 'cvs-ignore-marks-modif arg))
1192 1192
1193 (defun cvs-ignore-marks-p (cmd &optional read-only) 1193 (defun cvs-ignore-marks-p (cmd &optional read-only)
1194 (let ((default (if (member cmd cvs-invert-ignore-marks) 1194 (let ((default (if (member cmd cvs-invert-ignore-marks)
1195 (not cvs-default-ignore-marks) 1195 (not cvs-default-ignore-marks)
1196 cvs-default-ignore-marks)) 1196 cvs-default-ignore-marks))
1197 (modif (cvs-prefix-get 'cvs-ignore-marks-modif read-only))) 1197 (modif (cvs-prefix-get 'cvs-ignore-marks-modif read-only)))
1230 cvs-minor-current-files) 1230 cvs-minor-current-files)
1231 (or (and (not ignore-marks) 1231 (or (and (not ignore-marks)
1232 (ewoc-collect cvs-cookies 1232 (ewoc-collect cvs-cookies
1233 'cvs-fileinfo->marked)) 1233 'cvs-fileinfo->marked))
1234 (list (ewoc-data (ewoc-locate cvs-cookies (point))))))) 1234 (list (ewoc-data (ewoc-locate cvs-cookies (point)))))))
1235 1235
1236 (if (or ignore-contents (not (eq (cvs-fileinfo->type fi) 'DIRCHANGE))) 1236 (if (or ignore-contents (not (eq (cvs-fileinfo->type fi) 'DIRCHANGE)))
1237 (push fi fis) 1237 (push fi fis)
1238 ;; If a directory is selected, return members, if any. 1238 ;; If a directory is selected, return members, if any.
1239 (setq fis 1239 (setq fis
1240 (append (ewoc-collect cvs-cookies 1240 (append (ewoc-collect cvs-cookies
1313 (defun cvs-commit-filelist () (cvs-mode-files 'commit nil :read-only t :file t)) 1313 (defun cvs-commit-filelist () (cvs-mode-files 'commit nil :read-only t :file t))
1314 1314
1315 (defun cvs-do-commit (flags) 1315 (defun cvs-do-commit (flags)
1316 "Do the actual commit, using the current buffer as the log message." 1316 "Do the actual commit, using the current buffer as the log message."
1317 (interactive (list (cvs-flags-query 'cvs-commit-flags "cvs commit flags"))) 1317 (interactive (list (cvs-flags-query 'cvs-commit-flags "cvs commit flags")))
1318 (let ((msg (buffer-string))) 1318 (let ((msg (buffer-substring-no-properties (point-min) (point-max))))
1319 (cvs-mode!) 1319 (cvs-mode!)
1320 ;;(pop-to-buffer cvs-buffer) 1320 ;;(pop-to-buffer cvs-buffer)
1321 (cvs-mode-do "commit" (list* "-m" msg flags) 'commit))) 1321 (cvs-mode-do "commit" (list* "-m" msg flags) 'commit)))
1322 1322
1323 1323
1324 ;;;; 1324 ;;;;
1325 ;;;; CVS Mode commands 1325 ;;;; CVS Mode commands
1326 ;;;; 1326 ;;;;
1327 1327
1328 (defun-cvs-mode (cvs-mode-insert . NOARGS) (file) 1328 (defun-cvs-mode (cvs-mode-insert . NOARGS) (file)
1329 "Insert an entry for a specific file." 1329 "Insert an entry for a specific file."
1330 (interactive 1330 (interactive
1331 (list (read-file-name "File to insert: " nil nil nil 1331 (list (read-file-name "File to insert: " nil nil nil
1423 (defun cvs-emerge-merge (b1 b2 base out) 1423 (defun cvs-emerge-merge (b1 b2 base out)
1424 (emerge-buffers-with-ancestor b1 b2 base (find-file-noselect out))) 1424 (emerge-buffers-with-ancestor b1 b2 base (find-file-noselect out)))
1425 1425
1426 ;; 1426 ;;
1427 ;; Ediff support 1427 ;; Ediff support
1428 ;; 1428 ;;
1429 1429
1430 (defvar ediff-after-quit-destination-buffer) 1430 (defvar ediff-after-quit-destination-buffer)
1431 (defvar cvs-transient-buffers) 1431 (defvar cvs-transient-buffers)
1432 (defun cvs-ediff-startup-hook () 1432 (defun cvs-ediff-startup-hook ()
1433 (add-hook 'ediff-after-quit-hook-internal 1433 (add-hook 'ediff-after-quit-hook-internal
1880 (list (setq cvs-tag-name 1880 (list (setq cvs-tag-name
1881 (cvs-query-read cvs-tag-name "Tag to delete: " cvs-qtypedesc-tag)) 1881 (cvs-query-read cvs-tag-name "Tag to delete: " cvs-qtypedesc-tag))
1882 (cvs-flags-query 'cvs-tag-flags "tag flags"))) 1882 (cvs-flags-query 'cvs-tag-flags "tag flags")))
1883 (cvs-mode-do "tag" (append '("-d") flags (list tag)) 1883 (cvs-mode-do "tag" (append '("-d") flags (list tag))
1884 (when cvs-force-dir-tag 'tag))) 1884 (when cvs-force-dir-tag 'tag)))
1885 1885
1886 1886
1887 ;; Byte compile files. 1887 ;; Byte compile files.
1888 1888
1889 (defun-cvs-mode cvs-mode-byte-compile-files () 1889 (defun-cvs-mode cvs-mode-byte-compile-files ()
1890 "Run byte-compile-file on all selected files that end in '.el'." 1890 "Run byte-compile-file on all selected files that end in '.el'."
1939 "Internal function for `cvs-execute-single-file-list'." 1939 "Internal function for `cvs-execute-single-file-list'."
1940 (let* ((cur-dir (cvs-fileinfo->dir fi)) 1940 (let* ((cur-dir (cvs-fileinfo->dir fi))
1941 (default-directory (cvs-expand-dir-name cur-dir)) 1941 (default-directory (cvs-expand-dir-name cur-dir))
1942 (inhibit-read-only t) 1942 (inhibit-read-only t)
1943 (arg-list (funcall extractor fi))) 1943 (arg-list (funcall extractor fi)))
1944 1944
1945 ;; Execute the command unless extractor returned t. 1945 ;; Execute the command unless extractor returned t.
1946 (when (listp arg-list) 1946 (when (listp arg-list)
1947 (let* ((args (append constant-args arg-list))) 1947 (let* ((args (append constant-args arg-list)))
1948 1948
1949 (insert (format "=== cd %s\n=== %s %s\n\n" 1949 (insert (format "=== cd %s\n=== %s %s\n\n"
1950 cur-dir program (cvs-strings->string args))) 1950 cur-dir program (cvs-strings->string args)))
1951 1951
1952 ;; FIXME: return the exit status? 1952 ;; FIXME: return the exit status?
1953 (apply 'call-process program nil t t args) 1953 (apply 'call-process program nil t t args)
1954 (goto-char (point-max)))))) 1954 (goto-char (point-max))))))
1955 1955
1956 ;; FIXME: make this run in the background ala cvs-run-process... 1956 ;; FIXME: make this run in the background ala cvs-run-process...