emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 01/02: Propagate remote process environment.


From: Michael Albinus
Subject: [Emacs-diffs] master 01/02: Propagate remote process environment.
Date: Sat, 22 Nov 2014 11:39:20 +0000

branch: master
commit cd22fd754b71ff64bbabd05bb6df2df8fa5a8915
Author: Michael Albinus <address@hidden>
Date:   Sat Nov 22 12:37:04 2014 +0100

    Propagate remote process environment.
    
    * net/tramp-sh.el (tramp-sh-handle-start-file-process)
    (tramp-sh-handle-process-file): Propagate `process-environment'.
    
    * vc/vc-hg.el (vc-hg-state): No special handling for remote files;
    Tramp propagates environment variables now.
---
 lisp/ChangeLog       |   12 ++++++++++--
 lisp/net/tramp-sh.el |   35 ++++++++++++++++++++++++++++-------
 lisp/vc/vc-hg.el     |   17 +++++------------
 3 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 426543c..d3a9b64 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,10 +1,18 @@
+2014-11-22  Michael Albinus  <address@hidden>
+
+        * net/tramp-sh.el (tramp-sh-handle-start-file-process)
+       (tramp-sh-handle-process-file): Propagate `process-environment'.
+
+       * vc/vc-hg.el (vc-hg-state): No special handling for remote files;
+       Tramp propagates environment variables now.
+
 2014-11-22  Eric S. Raymond  <address@hidden>
 
-       * vc-filewise.el: New file to isolate code used only by the
+       * vc/vc-filewise.el: New file to isolate code used only by the
        file-oriented back ends (SCCS/RCS/CVS/SRC) which should not
        live in vc.el and certainly not in vc-hooks.el.
 
-       * vc-hooks.el, vc-rcs.el, vc-sccs.el: vc-name  -> vc-master-name.
+       * vc/vc-hooks.el, vc-rcs.el, vc-sccs.el: vc-name  -> vc-master-name.
        This is preaparatory to isolating all the 'master' functions
        used only by the file-oriented back ends.  With this done first,
        the substantive diffs will be easier to read.
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 6e46df2..8d7e046 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2835,16 +2835,27 @@ the result will be a local, non-Tramp, file name."
                        (list (replace-match " \\\\\n" nil nil (cadr args))))
                       (setq i (+ i 250))))
                   (cdr args)))
+          ;; Use a human-friendly prompt, for example for `shell'.
+          (prompt (format "PS1=%s"
+                          (format "%s %s"
+                                  (file-remote-p default-directory)
+                                  tramp-initial-end-of-output)))
+          ;; We use as environment the difference to toplevel
+          ;; `process-environment'.
+          env
+          (env
+           (dolist
+               (elt
+                (cons prompt (nreverse (copy-sequence process-environment)))
+                env)
+             (or (member elt (default-toplevel-value 'process-environment))
+                 (setq env (cons elt env)))))
           (command
            (when (stringp program)
-             (format "cd %s && exec %s env PS1=%s %s"
+             (format "cd %s && exec %s env %s %s"
                      (tramp-shell-quote-argument localname)
                      (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
-                     ;; Use a human-friendly prompt, for example for `shell'.
-                     (tramp-shell-quote-argument
-                      (format "%s %s"
-                              (file-remote-p default-directory)
-                              tramp-initial-end-of-output))
+                     (mapconcat 'tramp-shell-quote-argument env " ")
                      (if heredoc
                          (format "%s\n(\n%s\n) </dev/tty\n%s"
                                  program (car args) tramp-end-of-heredoc)
@@ -2931,10 +2942,20 @@ the result will be a local, non-Tramp, file name."
     (error "Implementation does not handle immediate return"))
 
   (with-parsed-tramp-file-name default-directory nil
-    (let (command input tmpinput stderr tmpstderr outbuf ret)
+    (let (command env input tmpinput stderr tmpstderr outbuf ret)
       ;; Compute command.
       (setq command (mapconcat 'tramp-shell-quote-argument
                               (cons program args) " "))
+      ;; We use as environment the difference to toplevel 
`process-environment'.
+      (setq env
+           (dolist (elt (nreverse (copy-sequence process-environment)) env)
+             (or (member elt (default-toplevel-value 'process-environment))
+                 (setq env (cons elt env)))))
+      (when env
+       (setq command
+             (format
+              "env %s %s"
+              (mapconcat 'tramp-shell-quote-argument env " ") command)))
       ;; Determine input.
       (if (null infile)
          (setq input "/dev/null")
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index dab2c72..62d0bb5 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -211,18 +211,11 @@ highlighting the Log View buffer."
                             (append
                              (list "TERM=dumb" "LANGUAGE=C" "HGPLAIN=1")
                              process-environment)))
-                       (if (file-remote-p file)
-                           (process-file
-                            "env" nil t nil
-                            "HGPLAIN=1" vc-hg-program
-                            "--config" "alias.status=status"
-                            "--config" "defaults.status="
-                            "status" "-A" (file-relative-name file))
-                         (process-file
-                          vc-hg-program nil t nil
-                          "--config" "alias.status=status"
-                          "--config" "defaults.status="
-                          "status" "-A" (file-relative-name file))))
+                       (process-file
+                        vc-hg-program nil t nil
+                        "--config" "alias.status=status"
+                        "--config" "defaults.status="
+                        "status" "-A" (file-relative-name file)))
                     ;; Some problem happened.  E.g. We can't find an `hg'
                     ;; executable.
                     (error nil)))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]