aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-09-03 01:40:29 +0000
committerStefan Monnier2002-09-03 01:40:29 +0000
commit6b2e4334c9e227ab16491870b3ff6f61dd848571 (patch)
tree9db6eb3336d1aa51381d6714ea70e3fa6d9f907b
parentf9e7890c824b1cea88c66c39e918c0928b54faf3 (diff)
downloademacs-6b2e4334c9e227ab16491870b3ff6f61dd848571.tar.gz
emacs-6b2e4334c9e227ab16491870b3ff6f61dd848571.zip
(cvs-run-process): Use a pty rather than a pipe to work
around the cvs/ssh/libc bug. (cvs-update-header): Understand `cvs admin -m<rev>:<msg>' syntax. (defun-cvs-mode): Use the new `declare' thingy. (cvs-edit-log-text-at-point, cvs-mode-edit-log, cvs-do-edit-log) (cvs-edit-log-minor-wrap, cvs-edit-log-filelist): New funs. (cvs-mode-undo): Use `cvs add' for (CONFLICT. REMOVED).
-rw-r--r--lisp/pcvs.el89
1 files changed, 83 insertions, 6 deletions
diff --git a/lisp/pcvs.el b/lisp/pcvs.el
index b8ec3e009ad..b1ec3d72b31 100644
--- a/lisp/pcvs.el
+++ b/lisp/pcvs.el
@@ -14,7 +14,7 @@
14;; (Jari Aalto+mail.emacs) jari.aalto@poboxes.com 14;; (Jari Aalto+mail.emacs) jari.aalto@poboxes.com
15;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu 15;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu
16;; Keywords: CVS, version control, release management 16;; Keywords: CVS, version control, release management
17;; Revision: $Id: pcvs.el,v 1.37 2002/06/24 22:49:38 monnier Exp $ 17;; Revision: $Id: pcvs.el,v 1.38 2002/06/25 00:11:28 monnier Exp $
18 18
19;; This file is part of GNU Emacs. 19;; This file is part of GNU Emacs.
20 20
@@ -537,7 +537,13 @@ Working dir: " (abbreviate-file-name dir) "
537 (if cvs-cvsroot (list "-d" cvs-cvsroot)) 537 (if cvs-cvsroot (list "-d" cvs-cvsroot))
538 args 538 args
539 files)) 539 files))
540 (process-connection-type nil) ; Use a pipe, not a pty. 540 ;; If process-connection-type is nil and the repository
541 ;; is accessed via SSH, a bad interaction between libc,
542 ;; CVS and SSH can lead to garbled output.
543 ;; It might be a glibc-specific problem.
544 ;; Until the problem is cleared, we'll use a pty rather than
545 ;; a pipe.
546 ;; (process-connection-type nil) ; Use a pipe, not a pty.
541 (process 547 (process
542 ;; the process will be run in the selected dir 548 ;; the process will be run in the selected dir
543 (let ((default-directory (cvs-expand-dir-name dir))) 549 (let ((default-directory (cvs-expand-dir-name dir)))
@@ -558,15 +564,23 @@ Working dir: " (abbreviate-file-name dir) "
558 564
559(defun cvs-update-header (args fis) ; inline 565(defun cvs-update-header (args fis) ; inline
560 (let* ((lastarg nil) 566 (let* ((lastarg nil)
561 ;; filter out the largish commit message
562 (args (mapcar (lambda (arg) 567 (args (mapcar (lambda (arg)
563 (cond 568 (cond
569 ;; filter out the largish commit message
564 ((and (eq lastarg nil) (string= arg "commit")) 570 ((and (eq lastarg nil) (string= arg "commit"))
565 (setq lastarg 'commit) arg) 571 (setq lastarg 'commit) arg)
566 ((and (eq lastarg 'commit) (string= arg "-m")) 572 ((and (eq lastarg 'commit) (string= arg "-m"))
567 (setq lastarg '-m) arg) 573 (setq lastarg '-m) arg)
568 ((eq lastarg '-m) 574 ((eq lastarg '-m)
569 (setq lastarg 'done) "<log message>") 575 (setq lastarg 'done) "<log message>")
576 ;; filter out the largish `admin -mrev:msg' message
577 ((and (eq lastarg nil) (string= arg "admin"))
578 (setq lastarg 'admin) arg)
579 ((and (eq lastarg 'admin)
580 (string-match "\\`-m[^:]*:" arg))
581 (setq lastarg 'done)
582 (concat (match-string 0 arg) "<log message>"))
583 ;; Keep the rest as is.
570 (t arg))) 584 (t arg)))
571 args)) 585 args))
572 ;; turn them into a string 586 ;; turn them into a string
@@ -626,6 +640,9 @@ it is finished."
626 (save-excursion (eval cvs-postproc)) 640 (save-excursion (eval cvs-postproc))
627 ;; check whether something is left 641 ;; check whether something is left
628 (unless cvs-postprocess 642 (unless cvs-postprocess
643 ;; IIRC, we enable undo again once the process is finished
644 ;; for cases where the output was inserted in *vc-diff* or
645 ;; in a file-like buffer. -stef
629 (buffer-enable-undo) 646 (buffer-enable-undo)
630 (with-current-buffer cvs-buffer 647 (with-current-buffer cvs-buffer
631 (cvs-update-header nil nil) ;FIXME: might need to be inline 648 (cvs-update-header nil nil) ;FIXME: might need to be inline
@@ -693,6 +710,7 @@ clear what alternative to use.
693- NOARGS will get all the arguments from the *cvs* buffer and will 710- NOARGS will get all the arguments from the *cvs* buffer and will
694 always behave as if called interactively. 711 always behave as if called interactively.
695- DOUBLE is the generic case." 712- DOUBLE is the generic case."
713 (declare (debug (&define sexp lambda-list stringp ("interactive" interactive) def-body)))
696 (let ((style (cvs-cdr fun)) 714 (let ((style (cvs-cdr fun))
697 (fun (cvs-car fun))) 715 (fun (cvs-car fun)))
698 (cond 716 (cond
@@ -727,7 +745,6 @@ before calling the real function `" (symbol-name fun-1) "'.\n")
727 (cvs-mode! ',fun-1))))) 745 (cvs-mode! ',fun-1)))))
728 746
729 (t (error "unknown style %s in `defun-cvs-mode'" style))))) 747 (t (error "unknown style %s in `defun-cvs-mode'" style)))))
730(def-edebug-spec defun-cvs-mode (&define sexp lambda-list stringp ("interactive" interactive) def-body))
731 748
732(defun-cvs-mode cvs-mode-kill-process () 749(defun-cvs-mode cvs-mode-kill-process ()
733 "Kill the temporary buffer and associated process." 750 "Kill the temporary buffer and associated process."
@@ -1049,7 +1066,7 @@ Full documentation is in the Texinfo file."
1049 ("" cvs-branch-prefix (cvs-secondary-branch-prefix 1066 ("" cvs-branch-prefix (cvs-secondary-branch-prefix
1050 ("->" cvs-secondary-branch-prefix)))) 1067 ("->" cvs-secondary-branch-prefix))))
1051 " " cvs-mode-line-process)) 1068 " " cvs-mode-line-process))
1052 (buffer-disable-undo (current-buffer)) 1069 (buffer-disable-undo)
1053 ;;(set (make-local-variable 'goal-column) cvs-cursor-column) 1070 ;;(set (make-local-variable 'goal-column) cvs-cursor-column)
1054 (set (make-local-variable 'revert-buffer-function) 'cvs-mode-revert-buffer) 1071 (set (make-local-variable 'revert-buffer-function) 'cvs-mode-revert-buffer)
1055 (setq truncate-lines t) 1072 (setq truncate-lines t)
@@ -1388,6 +1405,63 @@ The POSTPROC specified there (typically `log-edit') is then called,
1388 (cvs-mode-do "commit" (list* "-m" msg flags) 'commit))) 1405 (cvs-mode-do "commit" (list* "-m" msg flags) 'commit)))
1389 1406
1390 1407
1408;;;; Editing existing commit log messages.
1409
1410(defun cvs-edit-log-text-at-point ()
1411 (save-excursion
1412 (end-of-line)
1413 (when (re-search-backward "^revision " nil t)
1414 (forward-line 1)
1415 (if (looking-at "date:") (forward-line 1))
1416 (if (looking-at "branches:") (forward-line 1))
1417 (buffer-substring
1418 (point)
1419 (if (re-search-forward
1420 "^\\(-\\{28\\}\\|=\\{77\\}\\|revision [.0-9]+\\)$"
1421 nil t)
1422 (match-beginning 0)
1423 (point))))))
1424
1425(defun cvs-mode-edit-log (rev &optional text)
1426 "Edit the log message at point.
1427This is best called from a `log-view-mode' buffer."
1428 (interactive
1429 (list
1430 (or (cvs-mode! (lambda () (cvs-prefix-get 'cvs-branch-prefix)))
1431 (read-string "Revision to edit: "))
1432 (cvs-edit-log-text-at-point)))
1433 ;; It seems that the save-excursion that happens if I use the better
1434 ;; form of `(cvs-mode! (lambda ...))' screws up a couple things which
1435 ;; end up being rather annoying (like log-edit-mode's message being
1436 ;; displayed in the wrong minibuffer).
1437 (cvs-mode!)
1438 (let ((buf (cvs-temp-buffer "message" 'normal 'nosetup))
1439 (lbd list-buffers-directory)
1440 (setupfun (or (nth 2 (cdr (assoc "message" cvs-buffer-name-alist)))
1441 'log-edit)))
1442 (funcall setupfun 'cvs-do-edit-log nil 'cvs-edit-log-filelist buf)
1443 (when text (erase-buffer) (insert text))
1444 (set (make-local-variable 'cvs-edit-log-revision) rev)
1445 (set (make-local-variable 'cvs-minor-wrap-function) 'cvs-edit-log-minor-wrap)
1446 (set (make-local-variable 'list-buffers-directory) lbd)
1447 ;; (run-hooks 'cvs-mode-commit-hook)
1448 ))
1449
1450(defun cvs-edit-log-minor-wrap (buf f)
1451 (let ((cvs-ignore-marks-modif (cvs-mode-mark-get-modif "commit")))
1452 (funcall f)))
1453
1454(defun cvs-edit-log-filelist ()
1455 (cvs-mode-files nil nil :read-only t :file t :noquery t))
1456
1457(defun cvs-do-edit-log (rev)
1458 "Do the actual commit, using the current buffer as the log message."
1459 (interactive (list cvs-edit-log-revision))
1460 (let ((msg (buffer-substring-no-properties (point-min) (point-max))))
1461 (cvs-mode!)
1462 (cvs-mode-do "admin" (list (concat "-m" rev ":" msg)) nil)))
1463
1464
1391;;;; 1465;;;;
1392;;;; CVS Mode commands 1466;;;; CVS Mode commands
1393;;;; 1467;;;;
@@ -1850,7 +1924,10 @@ The file is removed and `cvs update FILE' is run."
1850 (interactive (list nil));; (cvs-flags-query 'cvs-undo-flags "undo flags") 1924 (interactive (list nil));; (cvs-flags-query 'cvs-undo-flags "undo flags")
1851 (if current-prefix-arg (call-interactively 'cvs-mode-revert-to-rev) 1925 (if current-prefix-arg (call-interactively 'cvs-mode-revert-to-rev)
1852 (let* ((fis (cvs-do-removal 'undo "update" 'all)) 1926 (let* ((fis (cvs-do-removal 'undo "update" 'all))
1853 (removedp (lambda (fi) (eq (cvs-fileinfo->type fi) 'REMOVED))) 1927 (removedp (lambda (fi)
1928 (or (eq (cvs-fileinfo->type fi) 'REMOVED)
1929 (and (eq (cvs-fileinfo->type fi) 'CONFLICT)
1930 (eq (cvs-fileinfo->subtype fi) 'REMOVED)))))
1854 (fis-split (cvs-partition removedp fis)) 1931 (fis-split (cvs-partition removedp fis))
1855 (fis-removed (car fis-split)) 1932 (fis-removed (car fis-split))
1856 (fis-other (cdr fis-split))) 1933 (fis-other (cdr fis-split)))