[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vc-hgcmd e39d484 29/87: fail gracefully if hg executabl
From: |
Stefan Monnier |
Subject: |
[elpa] externals/vc-hgcmd e39d484 29/87: fail gracefully if hg executable is absent |
Date: |
Sat, 5 Jun 2021 16:11:40 -0400 (EDT) |
branch: externals/vc-hgcmd
commit e39d4845ddf96ef702138314eab2fdf88e2fd9bb
Author: muffinmad <andreyk.mad@gmail.com>
Commit: muffinmad <andreyk.mad@gmail.com>
fail gracefully if hg executable is absent
---
vc-hgcmd.el | 84 ++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 47 insertions(+), 37 deletions(-)
diff --git a/vc-hgcmd.el b/vc-hgcmd.el
index 3d0d4d0..9b48243 100644
--- a/vc-hgcmd.el
+++ b/vc-hgcmd.el
@@ -5,7 +5,7 @@
;; Author: Andrii Kolomoiets <andreyk.mad@gmail.com>
;; Keywords: vc
;; URL: https://github.com/muffinmad/emacs-vc-hgcmd
-;; Package-Version: 1.3.2
+;; Package-Version: 1.3.3
;; Package-Requires: ((emacs "25.1"))
;; This file is NOT part of GNU Emacs.
@@ -237,23 +237,32 @@ Insert output to process buffer and check if amount of
data is enought to parse
(let ((process-environment (append vc-hgcmd-cmdserver-process-environment
process-environment))
(process-connection-type nil))
(with-current-buffer buffer
- (let ((process (apply
- #'start-file-process
- (concat "vc-hgcmd process: " (vc-hgcmd--project-name
default-directory))
- buffer
- vc-hgcmd-hg-executable
- vc-hgcmd-cmdserver-args)))
- (set-process-sentinel process #'ignore)
- (set-process-query-on-exit-flag process nil)
- (set-process-coding-system process 'no-conversion 'no-conversion)
- ;; read hello message
- ;; TODO parse encoding
- (while (not (vc-hgcmd--read-output))
- (accept-process-output process 0.1 nil t))
- ;; send \n after command data so tty process can read data
- (process-send-string process "runcommand\n")
- (set-process-filter process #'vc-hgcmd--cmdserver-process-filter)
- process)))))
+ (let ((inhibit-read-only t))
+ (erase-buffer))
+ (let ((process
+ (condition-case nil
+ (apply
+ #'start-file-process
+ (concat "vc-hgcmd process: " (vc-hgcmd--project-name
default-directory))
+ buffer
+ vc-hgcmd-hg-executable
+ vc-hgcmd-cmdserver-args)
+ (error nil))))
+ ;; process will be nil if hg executable not found
+ (when (process-live-p process)
+ (set-process-sentinel process #'ignore)
+ (set-process-query-on-exit-flag process nil)
+ (set-process-coding-system process 'no-conversion 'no-conversion)
+ ;; read hello message
+ ;; TODO parse encoding
+ ;; check process again because it can be tramp sh process with
output like "env: hg not found"
+ (while (and (process-live-p process) (not (vc-hgcmd--read-output)))
+ (accept-process-output process 0.1 nil t))
+ (when (process-live-p process)
+ ;; send \n after command data so tty process can read data
+ (process-send-string process "runcommand\n")
+ (set-process-filter process #'vc-hgcmd--cmdserver-process-filter)
+ process)))))))
(defun vc-hgcmd--repo-dir ()
"Get repo dir."
@@ -322,33 +331,34 @@ Insert 'Running command' and display buffer text if
COMMAND"
(defun vc-hgcmd--run-command (cmd)
"Run hg CMD."
(let* ((buffer (vc-hgcmd--process-buffer))
- (process (get-buffer-process buffer))
- (tty (process-tty-name process)))
+ (process (get-buffer-process buffer)))
(with-current-buffer buffer
(while vc-hgcmd--current-command
(accept-process-output process 0.1 nil t))
- (setq vc-hgcmd--current-command cmd)
- ;; send \n after command data so tty process can read data
- (process-send-string process (concat (vc-hgcmd--prepare-command-to-send
(vc-hgcmd--command-command cmd) tty) "runcommand\n"))
- (when (vc-hgcmd--command-wait cmd)
- (while vc-hgcmd--current-command
- (accept-process-output process 0.1 nil t))))))
+ (when (process-live-p process)
+ (setq vc-hgcmd--current-command cmd)
+ ;; send \n after command data so tty process can read data
+ (process-send-string process (concat
(vc-hgcmd--prepare-command-to-send (vc-hgcmd--command-command cmd)
(process-tty-name process)) "runcommand\n"))
+ (when (vc-hgcmd--command-wait cmd)
+ (while vc-hgcmd--current-command
+ (accept-process-output process 0.1 nil t)))
+ t))))
(defun vc-hgcmd-command (&rest command)
"Run hg COMMAND and return it's output."
(with-temp-buffer
(let ((cmd (make-vc-hgcmd--command :command command :output-buffer
(current-buffer) :wait t)))
- (vc-hgcmd--run-command cmd)
- (let ((result (string-trim-right (buffer-string))))
- ;; TODO min result code for each command that is not error
- (if (= (vc-hgcmd--command-result-code cmd) 255)
- (with-current-buffer (vc-hgcmd--get-output-buffer command)
- (goto-char (point-max))
- (let ((inhibit-read-only t))
- (insert (concat result "\n")))
- nil)
- (when (> (length result) 0)
- result))))))
+ (when (vc-hgcmd--run-command cmd)
+ (let ((result (string-trim-right (buffer-string))))
+ ;; TODO min result code for each command that is not error
+ (if (= (vc-hgcmd--command-result-code cmd) 255)
+ (with-current-buffer (vc-hgcmd--get-output-buffer command)
+ (goto-char (point-max))
+ (let ((inhibit-read-only t))
+ (insert (concat result "\n")))
+ nil)
+ (when (> (length result) 0)
+ result)))))))
(defun vc-hgcmd-command-output-buffer (buffer &rest command)
"Send output of COMMAND to BUFFER and wait COMMAND to finish."
- [elpa] externals/vc-hgcmd 48778bd 07/87: fixed typos, (continued)
- [elpa] externals/vc-hgcmd 48778bd 07/87: fixed typos, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 086e05d 10/87: fixed more typos, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd c6c8667 12/87: Don't pass abbreviated repo root dir to hg, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 15c3305 13/87: Don't pass abbreviated repo root dir to hg, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 9098970 05/87: removed unused format variable, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 0bfb041 04/87: Package-lint issues fixed, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd ca11232 08/87: fixed typos, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 8951533 18/87: Notes about installing from melpa, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd c95696f 15/87: Graph log for branch or root log, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd f48b82b 26/87: Filename must be relative to vc root, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd e39d484 29/87: fail gracefully if hg executable is absent,
Stefan Monnier <=
- [elpa] externals/vc-hgcmd aef3092 27/87: vc registered for symlinks fixed, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd e47e11b 28/87: don't pass relative file names to vc-state, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 88452e2 30/87: indentation, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 4556145 31/87: create hg process once, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd c62c14e 33/87: Use process-send-eof for pty processes, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 5416977 36/87: command callback must be called in output buffer, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 088aaa4 37/87: lazy completion table on branch merge, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 3e5782c 39/87: Handle unexpected output; Handle non-latin branch/file names, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 261ef39 21/87: version 1.3.1, Stefan Monnier, 2021/06/05
- [elpa] externals/vc-hgcmd 39dddda 22/87: Use relative filename on check status, Stefan Monnier, 2021/06/05