diff options
| author | Stefan Monnier | 2005-04-01 17:58:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2005-04-01 17:58:09 +0000 |
| commit | 8f53f317b1727fb63d343be28c985d3b73c8299f (patch) | |
| tree | 15745aaa33ce3ca002cb8b62317efde20abacf21 | |
| parent | 2e2255f62fa0543baf7c22c3e9dcf3a2361da62e (diff) | |
| download | emacs-8f53f317b1727fb63d343be28c985d3b73c8299f.tar.gz emacs-8f53f317b1727fb63d343be28c985d3b73c8299f.zip | |
(cvs-temp-buffer, cvs-mode-kill-process, cvs-buffer-check):
Use buffer-live-p.
(cvs-mode-run): Don't call cvs-update-header here.
(cvs-run-process): Call cvs-update-header.
Use process properties for cvs-postprocess and cvs-buffer so that
the sentinel can behave better if the temp buffer is killed.
Use a pipe rather than a tty, to better handle unexpected prompts.
(cvs-sentinel): Rewrite. Call cvs-update-header.
| -rw-r--r-- | lisp/pcvs.el | 105 |
1 files changed, 56 insertions, 49 deletions
diff --git a/lisp/pcvs.el b/lisp/pcvs.el index b00de07e50f..9ea0f311bed 100644 --- a/lisp/pcvs.el +++ b/lisp/pcvs.el | |||
| @@ -358,7 +358,7 @@ from the current buffer." | |||
| 358 | (dir default-directory) | 358 | (dir default-directory) |
| 359 | (buf (cond | 359 | (buf (cond |
| 360 | (name (cvs-get-buffer-create name)) | 360 | (name (cvs-get-buffer-create name)) |
| 361 | ((and (bufferp cvs-temp-buffer) (buffer-name cvs-temp-buffer)) | 361 | ((and (bufferp cvs-temp-buffer) (buffer-live-p cvs-temp-buffer)) |
| 362 | cvs-temp-buffer) | 362 | cvs-temp-buffer) |
| 363 | (t | 363 | (t |
| 364 | (set (make-local-variable 'cvs-temp-buffer) | 364 | (set (make-local-variable 'cvs-temp-buffer) |
| @@ -528,39 +528,49 @@ If non-nil, NEW means to create a new buffer no matter what." | |||
| 528 | (files (nth 1 dir+files+rest)) | 528 | (files (nth 1 dir+files+rest)) |
| 529 | (rest (nth 2 dir+files+rest))) | 529 | (rest (nth 2 dir+files+rest))) |
| 530 | 530 | ||
| 531 | ;; setup the (current) process buffer | ||
| 532 | (set (make-local-variable 'cvs-postprocess) | ||
| 533 | (if (null rest) | ||
| 534 | ;; this is the last invocation | ||
| 535 | postprocess | ||
| 536 | ;; else, we have to register ourselves to be rerun on the rest | ||
| 537 | `(cvs-run-process ',args ',rest ',postprocess ',single-dir))) | ||
| 538 | (add-hook 'kill-buffer-hook | 531 | (add-hook 'kill-buffer-hook |
| 539 | (lambda () | 532 | (lambda () |
| 540 | (let ((proc (get-buffer-process (current-buffer)))) | 533 | (let ((proc (get-buffer-process (current-buffer)))) |
| 541 | (when (processp proc) | 534 | (when (processp proc) |
| 542 | (set-process-filter proc nil) | 535 | (set-process-filter proc nil) |
| 543 | (set-process-sentinel proc nil) | 536 | ;; Abort postprocessing but leave the sentinel so it |
| 544 | (delete-process proc)))) | 537 | ;; will update the list of running procs. |
| 538 | (process-put proc 'cvs-postprocess nil) | ||
| 539 | (interrupt-process proc)))) | ||
| 545 | nil t) | 540 | nil t) |
| 546 | 541 | ||
| 547 | ;; create the new process and setup the procbuffer correspondingly | 542 | ;; create the new process and setup the procbuffer correspondingly |
| 548 | (let* ((args (append (cvs-flags-query 'cvs-cvs-flags nil 'noquery) | 543 | (let* ((msg (cvs-header-msg args fis)) |
| 544 | (args (append (cvs-flags-query 'cvs-cvs-flags nil 'noquery) | ||
| 549 | (if cvs-cvsroot (list "-d" cvs-cvsroot)) | 545 | (if cvs-cvsroot (list "-d" cvs-cvsroot)) |
| 550 | args | 546 | args |
| 551 | files)) | 547 | files)) |
| 552 | ;; If process-connection-type is nil and the repository | 548 | ;; If process-connection-type is nil and the repository |
| 553 | ;; is accessed via SSH, a bad interaction between libc, | 549 | ;; is accessed via SSH, a bad interaction between libc, |
| 554 | ;; CVS and SSH can lead to garbled output. | 550 | ;; CVS and SSH can lead to garbled output. |
| 555 | ;; It might be a glibc-specific problem (but it also happens | 551 | ;; It might be a glibc-specific problem (but it can also happens |
| 556 | ;; under Mac OS X, it seems). | 552 | ;; under Mac OS X, it seems). |
| 557 | ;; Until the problem is cleared, we'll use a pty rather than | 553 | ;; It seems that using a pty can help circumvent the problem, |
| 558 | ;; a pipe. | 554 | ;; but at the cost of screwing up when the process thinks it |
| 559 | ;; (process-connection-type nil) ; Use a pipe, not a pty. | 555 | ;; can ask for user input (such as password or host-key |
| 556 | ;; confirmation). A better workaround is to set CVS_RSH to | ||
| 557 | ;; an appropriate script, or to use a later version of CVS. | ||
| 558 | (process-connection-type nil) ; Use a pipe, not a pty. | ||
| 560 | (process | 559 | (process |
| 561 | ;; the process will be run in the selected dir | 560 | ;; the process will be run in the selected dir |
| 562 | (let ((default-directory (cvs-expand-dir-name dir))) | 561 | (let ((default-directory (cvs-expand-dir-name dir))) |
| 563 | (apply 'start-process "cvs" procbuf cvs-program args)))) | 562 | (apply 'start-process "cvs" procbuf cvs-program args)))) |
| 563 | ;; setup the process. | ||
| 564 | (process-put process 'cvs-buffer cvs-buffer) | ||
| 565 | (with-current-buffer cvs-buffer (cvs-update-header msg 'add)) | ||
| 566 | (process-put process 'cvs-header msg) | ||
| 567 | (process-put | ||
| 568 | process 'cvs-postprocess | ||
| 569 | (if (null rest) | ||
| 570 | ;; this is the last invocation | ||
| 571 | postprocess | ||
| 572 | ;; else, we have to register ourselves to be rerun on the rest | ||
| 573 | `(cvs-run-process ',args ',rest ',postprocess ',single-dir))) | ||
| 564 | (set-process-sentinel process 'cvs-sentinel) | 574 | (set-process-sentinel process 'cvs-sentinel) |
| 565 | (set-process-filter process 'cvs-update-filter) | 575 | (set-process-filter process 'cvs-update-filter) |
| 566 | (set-marker (process-mark process) (point-max)) | 576 | (set-marker (process-mark process) (point-max)) |
| @@ -636,33 +646,35 @@ If non-nil, NEW means to create a new buffer no matter what." | |||
| 636 | This is responsible for parsing the output from the cvs update when | 646 | This is responsible for parsing the output from the cvs update when |
| 637 | it is finished." | 647 | it is finished." |
| 638 | (when (memq (process-status proc) '(signal exit)) | 648 | (when (memq (process-status proc) '(signal exit)) |
| 639 | (if (null (buffer-name (process-buffer proc))) | 649 | (let ((cvs-postproc (process-get proc 'postprocess)) |
| 640 | ;;(set-process-buffer proc nil) | 650 | (cvs-buf (process-get proc 'cvs-buffer))) |
| 641 | (error "cvs' process buffer was killed") | 651 | ;; Since the buffer and mode line will show that the |
| 642 | (let* ((obuf (current-buffer)) | 652 | ;; process is dead, we can delete it now. Otherwise it |
| 643 | (procbuffer (process-buffer proc))) | 653 | ;; will stay around until M-x list-processes. |
| 644 | (set-buffer (with-current-buffer procbuffer cvs-buffer)) | 654 | (process-put proc 'postprocess nil) |
| 645 | (setq cvs-mode-line-process (symbol-name (process-status proc))) | 655 | (delete-process proc) |
| 646 | (force-mode-line-update) | 656 | ;; Don't do anything if the main buffer doesn't exist any more. |
| 647 | (set-buffer procbuffer) | 657 | (when (buffer-live-p cvs-buf) |
| 648 | (let ((cvs-postproc cvs-postprocess)) | 658 | (with-current-buffer cvs-buf |
| 649 | ;; Since the buffer and mode line will show that the | 659 | (cvs-update-header (process-get proc 'cvs-header) nil) |
| 650 | ;; process is dead, we can delete it now. Otherwise it | 660 | (setq cvs-mode-line-process (symbol-name (process-status proc))) |
| 651 | ;; will stay around until M-x list-processes. | 661 | (force-mode-line-update) |
| 652 | (delete-process proc) | 662 | (when cvs-postproc |
| 653 | (setq cvs-postprocess nil) | 663 | (if (null (buffer-live-p (process-buffer proc))) |
| 654 | ;; do the postprocessing like parsing and such | 664 | ;;(set-process-buffer proc nil) |
| 655 | (save-excursion (eval cvs-postproc)) | 665 | (error "cvs' process buffer was killed") |
| 656 | ;; check whether something is left | 666 | (with-current-buffer (process-buffer proc) |
| 657 | (unless cvs-postprocess | 667 | ;; do the postprocessing like parsing and such |
| 658 | ;; IIRC, we enable undo again once the process is finished | 668 | (save-excursion (eval cvs-postproc)) |
| 659 | ;; for cases where the output was inserted in *vc-diff* or | 669 | ;; check whether something is left |
| 660 | ;; in a file-like buffer. -stef | 670 | (unless (get-buffer-process (current-buffer)) |
| 661 | (buffer-enable-undo) | 671 | ;; IIRC, we enable undo again once the process is finished |
| 662 | (with-current-buffer cvs-buffer | 672 | ;; for cases where the output was inserted in *vc-diff* or |
| 663 | (message "CVS process has completed in %s" (buffer-name))))) | 673 | ;; in a file-like buffer. --Stef |
| 664 | ;; This might not even be necessary | 674 | (buffer-enable-undo) |
| 665 | (set-buffer obuf))))) | 675 | (with-current-buffer cvs-buffer |
| 676 | (message "CVS process has completed in %s" | ||
| 677 | (buffer-name)))))))))))) | ||
| 666 | 678 | ||
| 667 | (defun cvs-parse-process (dcd &optional subdir old-fis) | 679 | (defun cvs-parse-process (dcd &optional subdir old-fis) |
| 668 | "Parse the output of a cvs process. | 680 | "Parse the output of a cvs process. |
| @@ -770,7 +782,7 @@ before calling the real function `" (symbol-name fun-1) "'.\n") | |||
| 770 | (defun-cvs-mode cvs-mode-kill-process () | 782 | (defun-cvs-mode cvs-mode-kill-process () |
| 771 | "Kill the temporary buffer and associated process." | 783 | "Kill the temporary buffer and associated process." |
| 772 | (interactive) | 784 | (interactive) |
| 773 | (when (and (bufferp cvs-temp-buffer) (buffer-name cvs-temp-buffer)) | 785 | (when (and (bufferp cvs-temp-buffer) (buffer-live-p cvs-temp-buffer)) |
| 774 | (let ((proc (get-buffer-process cvs-temp-buffer))) | 786 | (let ((proc (get-buffer-process cvs-temp-buffer))) |
| 775 | (when proc (delete-process proc))))) | 787 | (when proc (delete-process proc))))) |
| 776 | 788 | ||
| @@ -1133,7 +1145,7 @@ Full documentation is in the Texinfo file." | |||
| 1133 | (eq (ewoc-buffer cvs-cookies) buf) | 1145 | (eq (ewoc-buffer cvs-cookies) buf) |
| 1134 | (setq check 'cvs-temp-buffer) | 1146 | (setq check 'cvs-temp-buffer) |
| 1135 | (or (null cvs-temp-buffer) | 1147 | (or (null cvs-temp-buffer) |
| 1136 | (null (buffer-name cvs-temp-buffer)) | 1148 | (null (buffer-live-p cvs-temp-buffer)) |
| 1137 | (and (eq (with-current-buffer cvs-temp-buffer cvs-buffer) buf) | 1149 | (and (eq (with-current-buffer cvs-temp-buffer cvs-buffer) buf) |
| 1138 | (equal (with-current-buffer cvs-temp-buffer | 1150 | (equal (with-current-buffer cvs-temp-buffer |
| 1139 | default-directory) | 1151 | default-directory) |
| @@ -1822,11 +1834,6 @@ POSTPROC is a list of expressions to be evaluated at the very end (after | |||
| 1822 | ;; absence of `cvs update' output has a specific meaning. | 1834 | ;; absence of `cvs update' output has a specific meaning. |
| 1823 | (or fis (list (cvs-create-fileinfo 'DIRCHANGE "" "." "")))))) | 1835 | (or fis (list (cvs-create-fileinfo 'DIRCHANGE "" "." "")))))) |
| 1824 | (push `(cvs-parse-process ',dont-change-disc nil ',old-fis) postproc))) | 1836 | (push `(cvs-parse-process ',dont-change-disc nil ',old-fis) postproc))) |
| 1825 | (let ((msg (cvs-header-msg args fis))) | ||
| 1826 | (cvs-update-header msg 'add) | ||
| 1827 | (push `(with-current-buffer cvs-buffer | ||
| 1828 | (cvs-update-header ',msg nil)) | ||
| 1829 | postproc)) | ||
| 1830 | (setq postproc (if (cdr postproc) (cons 'progn postproc) (car postproc))) | 1837 | (setq postproc (if (cdr postproc) (cons 'progn postproc) (car postproc))) |
| 1831 | (with-current-buffer buf | 1838 | (with-current-buffer buf |
| 1832 | (let ((inhibit-read-only t)) (erase-buffer)) | 1839 | (let ((inhibit-read-only t)) (erase-buffer)) |