]> git.eshelyaron.com Git - emacs.git/commitdiff
Adapt Tramp's progress-reporter messages
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 25 May 2024 09:34:04 +0000 (11:34 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 26 May 2024 05:57:10 +0000 (07:57 +0200)
* lisp/net/tramp-androidsu.el (tramp-androidsu-maybe-open-connection):
* lisp/net/tramp-gvfs.el (tramp-gvfs-maybe-open-connection):
Adapt progress-reporter message.

* lisp/net/tramp-sh.el (tramp-maybe-open-connection):
Divide progress-reporter into two parts.  (Bug#70901)

(cherry picked from commit 1a48b53040d1ec24798c07c7dacafe134aa15a5e)

lisp/net/tramp-androidsu.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el

index ee0241812eeacdd4f72b89af880a09942fddc93f..95b852d20683f35e529c10879011b83ad4fa95f1 100644 (file)
@@ -118,16 +118,14 @@ multibyte mode and waits for the shell prompt to appear."
          (unless (process-live-p p)
            (with-tramp-progress-reporter
                vec 3
-               (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec))
-                   (format "Opening connection %s for %s using %s"
-                           process-name
-                           (tramp-file-name-host vec)
-                           (tramp-file-name-method vec))
-                 (format "Opening connection %s for %s@%s using %s"
-                         process-name
-                         (tramp-file-name-user vec)
-                         (tramp-file-name-host vec)
-                         (tramp-file-name-method vec)))
+               (format "Opening connection%s for %s%s using %s"
+                       (if (tramp-string-empty-or-nil-p process-name)
+                           "" (concat " " process-name))
+                       (if (tramp-string-empty-or-nil-p
+                            (tramp-file-name-user vec))
+                           "" (concat (tramp-file-name-user vec) "@"))
+                       (tramp-file-name-host vec)
+                       (tramp-file-name-method vec))
               (let* ((coding-system-for-read 'utf-8-unix)
                      (process-connection-type tramp-process-connection-type)
                      ;; The executable loader cannot execute setuid
index 93071ed73509b43b4ca6cb0832cc8fa03c3af071..b1820b3e2fe0b57844b3d5a528c11b950b1ee1a9 100644 (file)
@@ -2245,10 +2245,10 @@ connection if a previous connection has died for some reason."
             (tramp-make-tramp-file-name vec 'noloc))))
 
        (with-tramp-progress-reporter
-           vec 3
-           (if (tramp-string-empty-or-nil-p user)
-               (format "Opening connection for %s using %s" host method)
-             (format "Opening connection for %s@%s using %s" user host method))
+           vec 3 (format "Opening connection for %s%s using %s"
+                         (if (tramp-string-empty-or-nil-p user)
+                             "" (concat user "@"))
+                         host method)
 
          ;; Enable `auth-source'.
          (tramp-set-connection-property
index 0767da0b6d2a8f59e11879f7dda4c069d7f58b64..350cbebe55056821fc6f32cb20a3f9f210f87021 100644 (file)
@@ -5272,193 +5272,194 @@ connection if a previous connection has died for some reason."
       ;; New connection must be opened.
       (condition-case err
          (unless (process-live-p p)
-           (with-tramp-progress-reporter
-               vec 3
-               (if (tramp-string-empty-or-nil-p (tramp-file-name-user vec))
-                   (format "Opening connection %s for %s using %s"
-                           process-name
-                           (tramp-file-name-host vec)
-                           (tramp-file-name-method vec))
-                 (format "Opening connection %s for %s@%s using %s"
-                         process-name
-                         (tramp-file-name-user vec)
-                         (tramp-file-name-host vec)
-                         (tramp-file-name-method vec)))
-
-             (catch 'uname-changed
-               ;; Start new process.
-               (when (and p (processp p))
-                 (delete-process p))
-               (setenv "TERM" tramp-terminal-type)
-               (setenv "LC_ALL" (tramp-get-local-locale vec))
-               (if (stringp tramp-histfile-override)
-                   (setenv "HISTFILE" tramp-histfile-override)
-                 (if tramp-histfile-override
-                     (progn
-                       (setenv "HISTFILE")
-                       (setenv "HISTFILESIZE" "0")
-                       (setenv "HISTSIZE" "0"))))
-               (setenv "PROMPT_COMMAND")
-               (setenv "PS1" tramp-initial-end-of-output)
-               (unless (stringp tramp-encoding-shell)
-                  (tramp-error vec 'file-error "`tramp-encoding-shell' not set"))
-               (let* ((current-host tramp-system-name)
-                      (target-alist (tramp-compute-multi-hops vec))
-                      (previous-hop tramp-null-hop)
-                      ;; We will apply `tramp-ssh-controlmaster-options'
-                      ;; only for the first hop.
-                      (options (tramp-ssh-controlmaster-options vec))
-                      (process-connection-type tramp-process-connection-type)
-                      (process-adaptive-read-buffering nil)
-                      ;; There are unfortunate settings for
-                      ;; "cmdproxy" on W32 systems.
-                      (process-coding-system-alist nil)
-                      (coding-system-for-read nil)
-                      (extra-args
-                       (tramp-get-sh-extra-args tramp-encoding-shell))
-                      ;; This must be done in order to avoid our file
-                      ;; name handler.
-                      (p (let ((default-directory
-                                tramp-compat-temporary-file-directory))
-                           (apply
-                            #'start-process
-                            (tramp-get-connection-name vec)
-                            (tramp-get-connection-buffer vec)
-                            (append
-                             `(,tramp-encoding-shell)
-                             (and extra-args (split-string extra-args))
-                             (and tramp-encoding-command-interactive
-                                  `(,tramp-encoding-command-interactive)))))))
-
-                 ;; This is needed for ssh or PuTTY based processes,
-                 ;; and only if the respective options are set.
-                 ;; Perhaps, the setting could be more fine-grained.
-                 ;; (process-put p 'tramp-shared-socket t)
-                 ;; Set sentinel.  Initialize variables.
-                 (set-process-sentinel p #'tramp-process-sentinel)
-                 (tramp-post-process-creation p vec)
-                 (setq tramp-current-connection (cons vec (current-time)))
-
-                 ;; Set connection-local variables.
-                 (tramp-set-connection-local-variables vec)
-
-                 ;; Check whether process is alive.
-                 (tramp-barf-if-no-shell-prompt
-                  p 10
-                  "Couldn't find local shell prompt for %s"
-                  tramp-encoding-shell)
-
-                 ;; Now do all the connections as specified.
-                 (while target-alist
-                   (let* ((hop (car target-alist))
-                          (l-method (tramp-file-name-method hop))
-                          (l-user (tramp-file-name-user hop))
-                          (l-domain (tramp-file-name-domain hop))
-                          (l-host (tramp-file-name-host hop))
-                          (l-port (tramp-file-name-port hop))
-                          (remote-shell
-                           (tramp-get-method-parameter hop 'tramp-remote-shell))
-                          (extra-args (tramp-get-sh-extra-args remote-shell))
-                          (async-args
-                           (flatten-tree
-                            (tramp-get-method-parameter hop 'tramp-async-args)))
-                          (connection-timeout
-                           (tramp-get-method-parameter
-                            hop 'tramp-connection-timeout
-                            tramp-connection-timeout))
-                          (command
-                           (tramp-get-method-parameter
-                            hop 'tramp-login-program))
-                          ;; We don't create the temporary file.  In
-                          ;; fact, it is just a prefix for the
-                          ;; ControlPath option of ssh; the real
-                          ;; temporary file has another name, and it
-                          ;; is created and protected by ssh.  It is
-                          ;; also removed by ssh when the connection
-                          ;; is closed.  The temporary file name is
-                          ;; cached in the main connection process,
-                          ;; therefore we cannot use
-                          ;; `tramp-get-connection-process'.
-                          (tmpfile
-                           (with-tramp-connection-property
-                               (tramp-get-process vec) "temp-file"
-                             (tramp-compat-make-temp-name)))
-                          r-shell)
-
-                     ;; Check, whether there is a restricted shell.
-                     (dolist (elt tramp-restricted-shell-hosts-alist)
-                       (when (string-match-p elt current-host)
-                         (setq r-shell t)))
-                     (setq current-host l-host)
-
-                     ;; Set password prompt vector.
+           (catch 'uname-changed
+             ;; Start new process.
+             (when (and p (processp p))
+               (delete-process p))
+             (setenv "TERM" tramp-terminal-type)
+             (setenv "LC_ALL" (tramp-get-local-locale vec))
+             (if (stringp tramp-histfile-override)
+                 (setenv "HISTFILE" tramp-histfile-override)
+               (if tramp-histfile-override
+                   (progn
+                     (setenv "HISTFILE")
+                     (setenv "HISTFILESIZE" "0")
+                     (setenv "HISTSIZE" "0"))))
+             (setenv "PROMPT_COMMAND")
+             (setenv "PS1" tramp-initial-end-of-output)
+             (unless (stringp tramp-encoding-shell)
+                (tramp-error vec 'file-error "`tramp-encoding-shell' not set"))
+             (let* ((current-host tramp-system-name)
+                    (target-alist (tramp-compute-multi-hops vec))
+                    (previous-hop tramp-null-hop)
+                    ;; We will apply `tramp-ssh-controlmaster-options'
+                    ;; only for the first hop.
+                    (options (tramp-ssh-controlmaster-options vec))
+                    (process-connection-type tramp-process-connection-type)
+                    (process-adaptive-read-buffering nil)
+                    ;; There are unfortunate settings for "cmdproxy"
+                    ;; on W32 systems.
+                    (process-coding-system-alist nil)
+                    (coding-system-for-read nil)
+                    (extra-args (tramp-get-sh-extra-args tramp-encoding-shell))
+                    ;; This must be done in order to avoid our file
+                    ;; name handler.
+                    (p (let ((default-directory
+                              tramp-compat-temporary-file-directory))
+                         (apply
+                          #'start-process
+                          (tramp-get-connection-name vec)
+                          (tramp-get-connection-buffer vec)
+                          (append
+                           `(,tramp-encoding-shell)
+                           (and extra-args (split-string extra-args))
+                           (and tramp-encoding-command-interactive
+                                `(,tramp-encoding-command-interactive)))))))
+
+               ;; This is needed for ssh or PuTTY based processes,
+               ;; and only if the respective options are set.
+               ;; Perhaps, the setting could be more fine-grained.
+               ;; (process-put p 'tramp-shared-socket t)
+               ;; Set sentinel.  Initialize variables.
+               (set-process-sentinel p #'tramp-process-sentinel)
+               (tramp-post-process-creation p vec)
+               (setq tramp-current-connection (cons vec (current-time)))
+
+               ;; Set connection-local variables.
+               (tramp-set-connection-local-variables vec)
+
+               ;; Check whether process is alive.
+               (tramp-barf-if-no-shell-prompt
+                p 10
+                "Couldn't find local shell prompt for %s"
+                tramp-encoding-shell)
+
+               ;; Now do all the connections as specified.
+               (while target-alist
+                 (let* ((hop (car target-alist))
+                        (l-method (tramp-file-name-method hop))
+                        (l-user (tramp-file-name-user hop))
+                        (l-domain (tramp-file-name-domain hop))
+                        (l-host (tramp-file-name-host hop))
+                        (l-port (tramp-file-name-port hop))
+                        (remote-shell
+                         (tramp-get-method-parameter hop 'tramp-remote-shell))
+                        (extra-args (tramp-get-sh-extra-args remote-shell))
+                        (async-args
+                         (flatten-tree
+                          (tramp-get-method-parameter hop 'tramp-async-args)))
+                        (connection-timeout
+                         (tramp-get-method-parameter
+                          hop 'tramp-connection-timeout
+                          tramp-connection-timeout))
+                        (command
+                         (tramp-get-method-parameter
+                          hop 'tramp-login-program))
+                        ;; We don't create the temporary file.  In
+                        ;; fact, it is just a prefix for the
+                        ;; ControlPath option of ssh; the real
+                        ;; temporary file has another name, and it is
+                        ;; created and protected by ssh.  It is also
+                        ;; removed by ssh when the connection is
+                        ;; closed.  The temporary file name is cached
+                        ;; in the main connection process, therefore
+                        ;; we cannot use
+                        ;; `tramp-get-connection-process'.
+                        (tmpfile
+                         (with-tramp-connection-property
+                             (tramp-get-process vec) "temp-file"
+                           (tramp-compat-make-temp-name)))
+                        r-shell)
+
+                   ;; Check, whether there is a restricted shell.
+                   (dolist (elt tramp-restricted-shell-hosts-alist)
+                     (when (string-match-p elt current-host)
+                       (setq r-shell t)))
+                   (setq current-host l-host)
+
+                   ;; Set password prompt vector.
+                   (tramp-set-connection-property
+                    p "password-vector"
+                    (if (tramp-get-method-parameter
+                         hop 'tramp-password-previous-hop)
+                        (let ((pv (copy-tramp-file-name previous-hop)))
+                          (setf (tramp-file-name-method pv) l-method)
+                          pv)
+                      (make-tramp-file-name
+                       :method l-method :user l-user :domain l-domain
+                       :host l-host :port l-port)))
+
+                   ;; Set session timeout.
+                   (when-let ((timeout
+                               (tramp-get-method-parameter
+                                hop 'tramp-session-timeout)))
                      (tramp-set-connection-property
-                      p "password-vector"
-                      (if (tramp-get-method-parameter
-                           hop 'tramp-password-previous-hop)
-                          (let ((pv (copy-tramp-file-name previous-hop)))
-                            (setf (tramp-file-name-method pv) l-method)
-                            pv)
-                        (make-tramp-file-name
-                         :method l-method :user l-user :domain l-domain
-                         :host l-host :port l-port)))
-
-                     ;; Set session timeout.
-                     (when-let ((timeout
-                                 (tramp-get-method-parameter
-                                  hop 'tramp-session-timeout)))
-                       (tramp-set-connection-property
-                        p "session-timeout" timeout))
-
-                     ;; Replace `login-args' place holders.
-                     (setq
-                      command
-                      (string-join
-                       (append
-                        ;; We do not want to see the trailing local
-                        ;; prompt in `start-file-process'.
-                        (unless r-shell '("exec"))
-                        `(,command)
-                        ;; Add arguments for asynchronous processes.
-                        (when process-name async-args)
-                        (tramp-expand-args
-                         hop 'tramp-login-args nil
-                         ?h (or l-host "") ?u (or l-user "") ?p (or l-port "")
-                         ?c (format-spec options (format-spec-make ?t tmpfile))
-                         ?n (concat
-                             "2>" (tramp-get-remote-null-device previous-hop))
-                         ?l (concat remote-shell " " extra-args " -i"))
-                        ;; A restricted shell does not allow "exec".
-                        (when r-shell '("&&" "exit")) '("||" "exit"))
-                       " "))
-
-                     ;; Send the command.
-                     (tramp-message vec 3 "Sending command `%s'" command)
+                      p "session-timeout" timeout))
+
+                   ;; Replace `login-args' place holders.
+                   (setq
+                    command
+                    (string-join
+                     (append
+                      ;; We do not want to see the trailing local
+                      ;; prompt in `start-file-process'.
+                      (unless r-shell '("exec"))
+                      `(,command)
+                      ;; Add arguments for asynchronous processes.
+                      (when process-name async-args)
+                      (tramp-expand-args
+                       hop 'tramp-login-args nil
+                       ?h (or l-host "") ?u (or l-user "") ?p (or l-port "")
+                       ?c (format-spec options (format-spec-make ?t tmpfile))
+                       ?n (concat
+                           "2>" (tramp-get-remote-null-device previous-hop))
+                       ?l (concat remote-shell " " extra-args " -i"))
+                      ;; A restricted shell does not allow "exec".
+                      (when r-shell '("&&" "exit")) '("||" "exit"))
+                     " "))
+
+                   ;; Send the command.
+                   (with-tramp-progress-reporter
+                       vec 3
+                       (format "Opening connection%s for %s%s using %s"
+                               (if (tramp-string-empty-or-nil-p process-name)
+                                   "" (concat " " process-name))
+                               (if (tramp-string-empty-or-nil-p l-user)
+                                   "" (concat l-user "@"))
+                               l-host l-method)
                      (tramp-send-command vec command t t)
                      (tramp-process-actions
                       p vec
                       (min
                        pos (with-current-buffer (process-buffer p) (point-max)))
-                      tramp-actions-before-shell connection-timeout)
-                     (tramp-message
-                      vec 3 "Found remote shell prompt on `%s'" l-host)
-
-                     ;; Next hop.
-                     (setq options ""
-                           target-alist (cdr target-alist)
-                           previous-hop hop)))
-
-                 ;; Activate session timeout.
-                 (when (tramp-get-connection-property p "session-timeout")
-                   (run-at-time
-                    (tramp-get-connection-property p "session-timeout") nil
-                    #'tramp-timeout-session vec))
-
-                 ;; Make initial shell settings.
-                 (tramp-open-connection-setup-interactive-shell p vec)
-
-                 ;; Mark it as connected.
-                 (tramp-set-connection-property p "connected" t)))))
+                      tramp-actions-before-shell connection-timeout))
+
+                   ;; Next hop.
+                   (setq options ""
+                         target-alist (cdr target-alist)
+                         previous-hop hop)))
+
+               ;; Activate session timeout.
+               (when (tramp-get-connection-property p "session-timeout")
+                 (run-at-time
+                  (tramp-get-connection-property p "session-timeout") nil
+                  #'tramp-timeout-session vec))
+
+               ;; Make initial shell settings.
+               (with-tramp-progress-reporter
+                   vec 3
+                   (format "Setup connection%s for %s%s using %s"
+                           (if (tramp-string-empty-or-nil-p process-name)
+                               "" (concat " " process-name))
+                           (if (tramp-string-empty-or-nil-p
+                                (tramp-file-name-user vec))
+                               "" (concat (tramp-file-name-user vec) "@"))
+                           (tramp-file-name-host vec)
+                           (tramp-file-name-method vec))
+                 (tramp-open-connection-setup-interactive-shell p vec))
+
+               ;; Mark it as connected.
+               (tramp-set-connection-property p "connected" t))))
 
        ;; Cleanup, and propagate the signal.
        ((error quit)