aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2015-07-29 21:07:01 +0200
committerMichael Albinus2015-07-29 21:07:01 +0200
commita53d1d325e0d1c0db6b407a776d6cfd3d12a90e0 (patch)
treede68585749739482d7acd167972a80f239a6e63c
parent33b779a11fb6785944383aeeae44f77cb580ee37 (diff)
downloademacs-a53d1d325e0d1c0db6b407a776d6cfd3d12a90e0.tar.gz
emacs-a53d1d325e0d1c0db6b407a776d6cfd3d12a90e0.zip
Fix Tramp problems with multihops, and nc.
* lisp/net/tramp-cache.el (tramp-get-file-property) (tramp-set-file-property, tramp-flush-file-property) (tramp-get-connection-property, tramp-set-connection-property) (tramp-flush-connection-property): Remove hop from vector. * lisp/net/tramp-gw.el (tramp-gw-process-filter): Ignore errors. * lisp/net/tramp-sh.el (tramp-methods) <nc>: Separate STDERR. (tramp-do-copy-or-rename-file-out-of-band): Increase timeout of netstat to 60". (tramp-sh-handle-start-file-process): Do not show hops in prompt. * lisp/net/tramp.el (tramp-handle-file-name-as-directory) (tramp-handle-file-name-directory, tramp-handle-file-remote-p): Keep hop in result. * test/automated/tramp-tests.el (tramp-test02-file-name-dissect): Add hop tests.
-rw-r--r--lisp/net/tramp-cache.el30
-rw-r--r--lisp/net/tramp-gw.el7
-rw-r--r--lisp/net/tramp-sh.el23
-rw-r--r--lisp/net/tramp.el9
-rw-r--r--test/automated/tramp-tests.el56
5 files changed, 90 insertions, 35 deletions
diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el
index 279d9f45c95..f777468c1ff 100644
--- a/lisp/net/tramp-cache.el
+++ b/lisp/net/tramp-cache.el
@@ -121,9 +121,10 @@ matching entries of `tramp-connection-properties'."
121(defun tramp-get-file-property (key file property default) 121(defun tramp-get-file-property (key file property default)
122 "Get the PROPERTY of FILE from the cache context of KEY. 122 "Get the PROPERTY of FILE from the cache context of KEY.
123Returns DEFAULT if not set." 123Returns DEFAULT if not set."
124 ;; Unify localname. 124 ;; Unify localname. Remove hop from vector.
125 (setq key (copy-sequence key)) 125 (setq key (copy-sequence key))
126 (aset key 3 (tramp-run-real-handler 'directory-file-name (list file))) 126 (aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
127 (aset key 4 nil)
127 (let* ((hash (tramp-get-hash-table key)) 128 (let* ((hash (tramp-get-hash-table key))
128 (value (when (hash-table-p hash) (gethash property hash)))) 129 (value (when (hash-table-p hash) (gethash property hash))))
129 (if 130 (if
@@ -153,9 +154,10 @@ Returns DEFAULT if not set."
153(defun tramp-set-file-property (key file property value) 154(defun tramp-set-file-property (key file property value)
154 "Set the PROPERTY of FILE to VALUE, in the cache context of KEY. 155 "Set the PROPERTY of FILE to VALUE, in the cache context of KEY.
155Returns VALUE." 156Returns VALUE."
156 ;; Unify localname. 157 ;; Unify localname. Remove hop from vector.
157 (setq key (copy-sequence key)) 158 (setq key (copy-sequence key))
158 (aset key 3 (tramp-run-real-handler 'directory-file-name (list file))) 159 (aset key 3 (tramp-run-real-handler 'directory-file-name (list file)))
160p (aset key 4 nil)
159 (let ((hash (tramp-get-hash-table key))) 161 (let ((hash (tramp-get-hash-table key)))
160 ;; We put the timestamp there. 162 ;; We put the timestamp there.
161 (puthash property (cons (current-time) value) hash) 163 (puthash property (cons (current-time) value) hash)
@@ -176,9 +178,10 @@ Returns VALUE."
176 (when (and (stringp truename) 178 (when (and (stringp truename)
177 (not (string-equal file (directory-file-name truename)))) 179 (not (string-equal file (directory-file-name truename))))
178 (tramp-flush-file-property key truename)) 180 (tramp-flush-file-property key truename))
179 ;; Unify localname. 181 ;; Unify localname. Remove hop from vector.
180 (setq key (copy-sequence key)) 182 (setq key (copy-sequence key))
181 (aset key 3 file) 183 (aset key 3 file)
184 (aset key 4 nil)
182 (tramp-message key 8 "%s" file) 185 (tramp-message key 8 "%s" file)
183 (remhash key tramp-cache-data))) 186 (remhash key tramp-cache-data)))
184 187
@@ -240,11 +243,12 @@ This is suppressed for temporary buffers."
240 "Get the named PROPERTY for the connection. 243 "Get the named PROPERTY for the connection.
241KEY identifies the connection, it is either a process or a vector. 244KEY identifies the connection, it is either a process or a vector.
242If the value is not set for the connection, returns DEFAULT." 245If the value is not set for the connection, returns DEFAULT."
243 ;; Unify key by removing localname from vector. Work with a copy in 246 ;; Unify key by removing localname and hop from vector. Work with a
244 ;; order to avoid side effects. 247 ;; copy in order to avoid side effects.
245 (when (vectorp key) 248 (when (vectorp key)
246 (setq key (copy-sequence key)) 249 (setq key (copy-sequence key))
247 (aset key 3 nil)) 250 (aset key 3 nil)
251 (aset key 4 nil))
248 (let* ((hash (tramp-get-hash-table key)) 252 (let* ((hash (tramp-get-hash-table key))
249 (value (if (hash-table-p hash) 253 (value (if (hash-table-p hash)
250 (gethash property hash default) 254 (gethash property hash default)
@@ -257,11 +261,12 @@ If the value is not set for the connection, returns DEFAULT."
257 "Set the named PROPERTY of a connection to VALUE. 261 "Set the named PROPERTY of a connection to VALUE.
258KEY identifies the connection, it is either a process or a vector. 262KEY identifies the connection, it is either a process or a vector.
259PROPERTY is set persistent when KEY is a vector." 263PROPERTY is set persistent when KEY is a vector."
260 ;; Unify key by removing localname from vector. Work with a copy in 264 ;; Unify key by removing localname and hop from vector. Work with a
261 ;; order to avoid side effects. 265 ;; copy in order to avoid side effects.
262 (when (vectorp key) 266 (when (vectorp key)
263 (setq key (copy-sequence key)) 267 (setq key (copy-sequence key))
264 (aset key 3 nil)) 268 (aset key 3 nil)
269 (aset key 4 nil))
265 (let ((hash (tramp-get-hash-table key))) 270 (let ((hash (tramp-get-hash-table key)))
266 (puthash property value hash) 271 (puthash property value hash)
267 (setq tramp-cache-data-changed t) 272 (setq tramp-cache-data-changed t)
@@ -278,11 +283,12 @@ KEY identifies the connection, it is either a process or a vector."
278(defun tramp-flush-connection-property (key) 283(defun tramp-flush-connection-property (key)
279 "Remove all properties identified by KEY. 284 "Remove all properties identified by KEY.
280KEY identifies the connection, it is either a process or a vector." 285KEY identifies the connection, it is either a process or a vector."
281 ;; Unify key by removing localname from vector. Work with a copy in 286 ;; Unify key by removing localname and hop from vector. Work with a
282 ;; order to avoid side effects. 287 ;; copy in order to avoid side effects.
283 (when (vectorp key) 288 (when (vectorp key)
284 (setq key (copy-sequence key)) 289 (setq key (copy-sequence key))
285 (aset key 3 nil)) 290 (aset key 3 nil)
291 (aset key 4 nil))
286 (tramp-message 292 (tramp-message
287 key 7 "%s %s" key 293 key 7 "%s %s" key
288 (let ((hash (gethash key tramp-cache-data)) 294 (let ((hash (gethash key tramp-cache-data))
diff --git a/lisp/net/tramp-gw.el b/lisp/net/tramp-gw.el
index 16eff8ca9e0..5e22f6a3b59 100644
--- a/lisp/net/tramp-gw.el
+++ b/lisp/net/tramp-gw.el
@@ -126,8 +126,11 @@
126 126
127(defun tramp-gw-process-filter (proc string) 127(defun tramp-gw-process-filter (proc string)
128 (let ((tramp-verbose 0)) 128 (let ((tramp-verbose 0))
129 (process-send-string 129 ;; The other process might have been stopped already. We don't
130 (tramp-get-connection-property proc "process" nil) string))) 130 ;; want to be interrupted then.
131 (ignore-errors
132 (process-send-string
133 (tramp-get-connection-property proc "process" nil) string))))
131 134
132;;;###tramp-autoload 135;;;###tramp-autoload
133(defun tramp-gw-open-connection (vec gw-vec target-vec) 136(defun tramp-gw-open-connection (vec gw-vec target-vec)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 670ff4b0cf7..bb939bf2df8 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -273,7 +273,7 @@ The string is used in `tramp-methods'.")
273 ;; We use "-p" as required for newer busyboxes. For older 273 ;; We use "-p" as required for newer busyboxes. For older
274 ;; busybox/nc versions, the value must be (("-l") ("%r")). This 274 ;; busybox/nc versions, the value must be (("-l") ("%r")). This
275 ;; can be achieved by tweaking `tramp-connection-properties'. 275 ;; can be achieved by tweaking `tramp-connection-properties'.
276 (tramp-remote-copy-args (("-l") ("-p" "%r"))) 276 (tramp-remote-copy-args (("-l") ("-p" "%r") ("2>/dev/null")))
277 (tramp-default-port 23))) 277 (tramp-default-port 23)))
278;;;###tramp-autoload 278;;;###tramp-autoload
279(add-to-list 'tramp-methods 279(add-to-list 'tramp-methods
@@ -2477,10 +2477,10 @@ The method used must be an out-of-band method."
2477 " ")) 2477 " "))
2478 (tramp-send-command v remote-copy-program) 2478 (tramp-send-command v remote-copy-program)
2479 (with-timeout 2479 (with-timeout
2480 (1 (tramp-error 2480 (60 (tramp-error
2481 v 'file-error 2481 v 'file-error
2482 "Listener process not running on remote host: `%s'" 2482 "Listener process not running on remote host: `%s'"
2483 remote-copy-program)) 2483 remote-copy-program))
2484 (tramp-send-command v (format "netstat -l | grep -q :%s" listener)) 2484 (tramp-send-command v (format "netstat -l | grep -q :%s" listener))
2485 (while (not (tramp-send-command-and-check v nil)) 2485 (while (not (tramp-send-command-and-check v nil))
2486 (tramp-send-command 2486 (tramp-send-command
@@ -2911,10 +2911,15 @@ the result will be a local, non-Tramp, file name."
2911 (setq i (+ i 250)))) 2911 (setq i (+ i 250))))
2912 (cdr args))) 2912 (cdr args)))
2913 ;; Use a human-friendly prompt, for example for `shell'. 2913 ;; Use a human-friendly prompt, for example for `shell'.
2914 (prompt (format "PS1=%s" 2914 ;; We discard hops, if existing, that's why we cannot use
2915 (format "%s %s" 2915 ;; `file-remote-p'.
2916 (file-remote-p default-directory) 2916 (prompt (format "PS1=%s %s"
2917 tramp-initial-end-of-output))) 2917 (tramp-make-tramp-file-name
2918 (tramp-file-name-method v)
2919 (tramp-file-name-user v)
2920 (tramp-file-name-host v)
2921 (tramp-file-name-localname v))
2922 tramp-initial-end-of-output))
2918 ;; We use as environment the difference to toplevel 2923 ;; We use as environment the difference to toplevel
2919 ;; `process-environment'. 2924 ;; `process-environment'.
2920 env 2925 env
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index beb87f61aaa..e15732182d7 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2927,7 +2927,8 @@ User is always nil."
2927 (tramp-file-name-user v) 2927 (tramp-file-name-user v)
2928 (tramp-file-name-host v) 2928 (tramp-file-name-host v)
2929 (tramp-run-real-handler 2929 (tramp-run-real-handler
2930 'file-name-as-directory (list (or (tramp-file-name-localname v) "")))))) 2930 'file-name-as-directory (list (or (tramp-file-name-localname v) "")))
2931 (tramp-file-name-hop v))))
2931 2932
2932(defun tramp-handle-file-name-completion 2933(defun tramp-handle-file-name-completion
2933 (filename directory &optional predicate) 2934 (filename directory &optional predicate)
@@ -2955,7 +2956,8 @@ User is always nil."
2955 (tramp-file-name-user v) 2956 (tramp-file-name-user v)
2956 (tramp-file-name-host v) 2957 (tramp-file-name-host v)
2957 (tramp-run-real-handler 2958 (tramp-run-real-handler
2958 'file-name-directory (list (or (tramp-file-name-localname v) "")))))) 2959 'file-name-directory (list (or (tramp-file-name-localname v) "")))
2960 (tramp-file-name-hop v))))
2959 2961
2960(defun tramp-handle-file-name-nondirectory (file) 2962(defun tramp-handle-file-name-nondirectory (file)
2961 "Like `file-name-nondirectory' but aware of Tramp files." 2963 "Like `file-name-nondirectory' but aware of Tramp files."
@@ -2992,7 +2994,8 @@ User is always nil."
2992 ((eq identification 'user) user) 2994 ((eq identification 'user) user)
2993 ((eq identification 'host) host) 2995 ((eq identification 'host) host)
2994 ((eq identification 'localname) localname) 2996 ((eq identification 'localname) localname)
2995 (t (tramp-make-tramp-file-name method user host ""))))))))) 2997 ((eq identification 'hop) hop)
2998 (t (tramp-make-tramp-file-name method user host "" hop)))))))))
2996 2999
2997(defun tramp-handle-file-symlink-p (filename) 3000(defun tramp-handle-file-symlink-p (filename)
2998 "Like `file-symlink-p' for Tramp files." 3001 "Like `file-symlink-p' for Tramp files."
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el
index a03dbf30b18..e6f77e42499 100644
--- a/test/automated/tramp-tests.el
+++ b/test/automated/tramp-tests.el
@@ -213,6 +213,7 @@ shall not contain a timeout."
213 (should (string-equal (file-remote-p "/method::" 'user) "default-user")) 213 (should (string-equal (file-remote-p "/method::" 'user) "default-user"))
214 (should (string-equal (file-remote-p "/method::" 'host) "default-host")) 214 (should (string-equal (file-remote-p "/method::" 'host) "default-host"))
215 (should (string-equal (file-remote-p "/method::" 'localname) "")) 215 (should (string-equal (file-remote-p "/method::" 'localname) ""))
216 (should (string-equal (file-remote-p "/method::" 'hop) nil))
216 217
217 ;; Expand `tramp-default-method' and `tramp-default-user'. 218 ;; Expand `tramp-default-method' and `tramp-default-user'.
218 (should (string-equal 219 (should (string-equal
@@ -222,6 +223,7 @@ shall not contain a timeout."
222 (should (string-equal (file-remote-p "/host:" 'user) "default-user")) 223 (should (string-equal (file-remote-p "/host:" 'user) "default-user"))
223 (should (string-equal (file-remote-p "/host:" 'host) "host")) 224 (should (string-equal (file-remote-p "/host:" 'host) "host"))
224 (should (string-equal (file-remote-p "/host:" 'localname) "")) 225 (should (string-equal (file-remote-p "/host:" 'localname) ""))
226 (should (string-equal (file-remote-p "/host:" 'hop) nil))
225 227
226 ;; Expand `tramp-default-method' and `tramp-default-host'. 228 ;; Expand `tramp-default-method' and `tramp-default-host'.
227 (should (string-equal 229 (should (string-equal
@@ -231,6 +233,7 @@ shall not contain a timeout."
231 (should (string-equal (file-remote-p "/user@:" 'user) "user")) 233 (should (string-equal (file-remote-p "/user@:" 'user) "user"))
232 (should (string-equal (file-remote-p "/user@:" 'host) "default-host")) 234 (should (string-equal (file-remote-p "/user@:" 'host) "default-host"))
233 (should (string-equal (file-remote-p "/user@:" 'localname) "")) 235 (should (string-equal (file-remote-p "/user@:" 'localname) ""))
236 (should (string-equal (file-remote-p "/user@:" 'hop) nil))
234 237
235 ;; Expand `tramp-default-method'. 238 ;; Expand `tramp-default-method'.
236 (should (string-equal 239 (should (string-equal
@@ -241,6 +244,7 @@ shall not contain a timeout."
241 (should (string-equal (file-remote-p "/user@host:" 'user) "user")) 244 (should (string-equal (file-remote-p "/user@host:" 'user) "user"))
242 (should (string-equal (file-remote-p "/user@host:" 'host) "host")) 245 (should (string-equal (file-remote-p "/user@host:" 'host) "host"))
243 (should (string-equal (file-remote-p "/user@host:" 'localname) "")) 246 (should (string-equal (file-remote-p "/user@host:" 'localname) ""))
247 (should (string-equal (file-remote-p "/user@host:" 'hop) nil))
244 248
245 ;; Expand `tramp-default-user'. 249 ;; Expand `tramp-default-user'.
246 (should (string-equal 250 (should (string-equal
@@ -250,6 +254,7 @@ shall not contain a timeout."
250 (should (string-equal (file-remote-p "/method:host:" 'user) "default-user")) 254 (should (string-equal (file-remote-p "/method:host:" 'user) "default-user"))
251 (should (string-equal (file-remote-p "/method:host:" 'host) "host")) 255 (should (string-equal (file-remote-p "/method:host:" 'host) "host"))
252 (should (string-equal (file-remote-p "/method:host:" 'localname) "")) 256 (should (string-equal (file-remote-p "/method:host:" 'localname) ""))
257 (should (string-equal (file-remote-p "/method:host:" 'hop) nil))
253 258
254 ;; Expand `tramp-default-host'. 259 ;; Expand `tramp-default-host'.
255 (should (string-equal 260 (should (string-equal
@@ -260,6 +265,7 @@ shall not contain a timeout."
260 (should (string-equal (file-remote-p "/method:user@:" 'host) 265 (should (string-equal (file-remote-p "/method:user@:" 'host)
261 "default-host")) 266 "default-host"))
262 (should (string-equal (file-remote-p "/method:user@:" 'localname) "")) 267 (should (string-equal (file-remote-p "/method:user@:" 'localname) ""))
268 (should (string-equal (file-remote-p "/method:user@:" 'hop) nil))
263 269
264 ;; No expansion. 270 ;; No expansion.
265 (should (string-equal 271 (should (string-equal
@@ -270,6 +276,7 @@ shall not contain a timeout."
270 (should (string-equal (file-remote-p "/method:user@host:" 'user) "user")) 276 (should (string-equal (file-remote-p "/method:user@host:" 'user) "user"))
271 (should (string-equal (file-remote-p "/method:user@host:" 'host) "host")) 277 (should (string-equal (file-remote-p "/method:user@host:" 'host) "host"))
272 (should (string-equal (file-remote-p "/method:user@host:" 'localname) "")) 278 (should (string-equal (file-remote-p "/method:user@host:" 'localname) ""))
279 (should (string-equal (file-remote-p "/method:user@host:" 'hop) nil))
273 280
274 ;; No expansion. 281 ;; No expansion.
275 (should (string-equal 282 (should (string-equal
@@ -283,6 +290,8 @@ shall not contain a timeout."
283 (file-remote-p "/method:user@email@host:" 'host) "host")) 290 (file-remote-p "/method:user@email@host:" 'host) "host"))
284 (should (string-equal 291 (should (string-equal
285 (file-remote-p "/method:user@email@host:" 'localname) "")) 292 (file-remote-p "/method:user@email@host:" 'localname) ""))
293 (should (string-equal
294 (file-remote-p "/method:user@email@host:" 'hop) nil))
286 295
287 ;; Expand `tramp-default-method' and `tramp-default-user'. 296 ;; Expand `tramp-default-method' and `tramp-default-user'.
288 (should (string-equal 297 (should (string-equal
@@ -293,6 +302,7 @@ shall not contain a timeout."
293 (should (string-equal (file-remote-p "/host#1234:" 'user) "default-user")) 302 (should (string-equal (file-remote-p "/host#1234:" 'user) "default-user"))
294 (should (string-equal (file-remote-p "/host#1234:" 'host) "host#1234")) 303 (should (string-equal (file-remote-p "/host#1234:" 'host) "host#1234"))
295 (should (string-equal (file-remote-p "/host#1234:" 'localname) "")) 304 (should (string-equal (file-remote-p "/host#1234:" 'localname) ""))
305 (should (string-equal (file-remote-p "/host#1234:" 'hop) nil))
296 306
297 ;; Expand `tramp-default-method'. 307 ;; Expand `tramp-default-method'.
298 (should (string-equal 308 (should (string-equal
@@ -303,6 +313,7 @@ shall not contain a timeout."
303 (should (string-equal (file-remote-p "/user@host#1234:" 'user) "user")) 313 (should (string-equal (file-remote-p "/user@host#1234:" 'user) "user"))
304 (should (string-equal (file-remote-p "/user@host#1234:" 'host) "host#1234")) 314 (should (string-equal (file-remote-p "/user@host#1234:" 'host) "host#1234"))
305 (should (string-equal (file-remote-p "/user@host#1234:" 'localname) "")) 315 (should (string-equal (file-remote-p "/user@host#1234:" 'localname) ""))
316 (should (string-equal (file-remote-p "/user@host#1234:" 'hop) nil))
306 317
307 ;; Expand `tramp-default-user'. 318 ;; Expand `tramp-default-user'.
308 (should (string-equal 319 (should (string-equal
@@ -315,6 +326,7 @@ shall not contain a timeout."
315 (should (string-equal 326 (should (string-equal
316 (file-remote-p "/method:host#1234:" 'host) "host#1234")) 327 (file-remote-p "/method:host#1234:" 'host) "host#1234"))
317 (should (string-equal (file-remote-p "/method:host#1234:" 'localname) "")) 328 (should (string-equal (file-remote-p "/method:host#1234:" 'localname) ""))
329 (should (string-equal (file-remote-p "/method:host#1234:" 'hop) nil))
318 330
319 ;; No expansion. 331 ;; No expansion.
320 (should (string-equal 332 (should (string-equal
@@ -328,6 +340,8 @@ shall not contain a timeout."
328 (file-remote-p "/method:user@host#1234:" 'host) "host#1234")) 340 (file-remote-p "/method:user@host#1234:" 'host) "host#1234"))
329 (should (string-equal 341 (should (string-equal
330 (file-remote-p "/method:user@host#1234:" 'localname) "")) 342 (file-remote-p "/method:user@host#1234:" 'localname) ""))
343 (should (string-equal
344 (file-remote-p "/method:user@host#1234:" 'hop) nil))
331 345
332 ;; Expand `tramp-default-method' and `tramp-default-user'. 346 ;; Expand `tramp-default-method' and `tramp-default-user'.
333 (should (string-equal 347 (should (string-equal
@@ -337,6 +351,7 @@ shall not contain a timeout."
337 (should (string-equal (file-remote-p "/1.2.3.4:" 'user) "default-user")) 351 (should (string-equal (file-remote-p "/1.2.3.4:" 'user) "default-user"))
338 (should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4")) 352 (should (string-equal (file-remote-p "/1.2.3.4:" 'host) "1.2.3.4"))
339 (should (string-equal (file-remote-p "/1.2.3.4:" 'localname) "")) 353 (should (string-equal (file-remote-p "/1.2.3.4:" 'localname) ""))
354 (should (string-equal (file-remote-p "/1.2.3.4:" 'hop) nil))
340 355
341 ;; Expand `tramp-default-method'. 356 ;; Expand `tramp-default-method'.
342 (should (string-equal 357 (should (string-equal
@@ -347,6 +362,7 @@ shall not contain a timeout."
347 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user")) 362 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'user) "user"))
348 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4")) 363 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'host) "1.2.3.4"))
349 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) "")) 364 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'localname) ""))
365 (should (string-equal (file-remote-p "/user@1.2.3.4:" 'hop) nil))
350 366
351 ;; Expand `tramp-default-user'. 367 ;; Expand `tramp-default-user'.
352 (should (string-equal 368 (should (string-equal
@@ -357,6 +373,7 @@ shall not contain a timeout."
357 (file-remote-p "/method:1.2.3.4:" 'user) "default-user")) 373 (file-remote-p "/method:1.2.3.4:" 'user) "default-user"))
358 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'host) "1.2.3.4")) 374 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'host) "1.2.3.4"))
359 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'localname) "")) 375 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'localname) ""))
376 (should (string-equal (file-remote-p "/method:1.2.3.4:" 'hop) nil))
360 377
361 ;; No expansion. 378 ;; No expansion.
362 (should (string-equal 379 (should (string-equal
@@ -369,6 +386,8 @@ shall not contain a timeout."
369 (file-remote-p "/method:user@1.2.3.4:" 'host) "1.2.3.4")) 386 (file-remote-p "/method:user@1.2.3.4:" 'host) "1.2.3.4"))
370 (should (string-equal 387 (should (string-equal
371 (file-remote-p "/method:user@1.2.3.4:" 'localname) "")) 388 (file-remote-p "/method:user@1.2.3.4:" 'localname) ""))
389 (should (string-equal
390 (file-remote-p "/method:user@1.2.3.4:" 'hop) nil))
372 391
373 ;; Expand `tramp-default-method', `tramp-default-user' and 392 ;; Expand `tramp-default-method', `tramp-default-user' and
374 ;; `tramp-default-host'. 393 ;; `tramp-default-host'.
@@ -380,6 +399,7 @@ shall not contain a timeout."
380 (should (string-equal (file-remote-p "/[]:" 'user) "default-user")) 399 (should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
381 (should (string-equal (file-remote-p "/[]:" 'host) "default-host")) 400 (should (string-equal (file-remote-p "/[]:" 'host) "default-host"))
382 (should (string-equal (file-remote-p "/[]:" 'localname) "")) 401 (should (string-equal (file-remote-p "/[]:" 'localname) ""))
402 (should (string-equal (file-remote-p "/[]:" 'hop) nil))
383 403
384 ;; Expand `tramp-default-method' and `tramp-default-user'. 404 ;; Expand `tramp-default-method' and `tramp-default-user'.
385 (let ((tramp-default-host "::1")) 405 (let ((tramp-default-host "::1"))
@@ -389,7 +409,8 @@ shall not contain a timeout."
389 (should (string-equal (file-remote-p "/[]:" 'method) "default-method")) 409 (should (string-equal (file-remote-p "/[]:" 'method) "default-method"))
390 (should (string-equal (file-remote-p "/[]:" 'user) "default-user")) 410 (should (string-equal (file-remote-p "/[]:" 'user) "default-user"))
391 (should (string-equal (file-remote-p "/[]:" 'host) "::1")) 411 (should (string-equal (file-remote-p "/[]:" 'host) "::1"))
392 (should (string-equal (file-remote-p "/[]:" 'localname) ""))) 412 (should (string-equal (file-remote-p "/[]:" 'localname) ""))
413 (should (string-equal (file-remote-p "/[]:" 'hop) nil)))
393 414
394 ;; Expand `tramp-default-method' and `tramp-default-user'. 415 ;; Expand `tramp-default-method' and `tramp-default-user'.
395 (should (string-equal 416 (should (string-equal
@@ -399,6 +420,7 @@ shall not contain a timeout."
399 (should (string-equal (file-remote-p "/[::1]:" 'user) "default-user")) 420 (should (string-equal (file-remote-p "/[::1]:" 'user) "default-user"))
400 (should (string-equal (file-remote-p "/[::1]:" 'host) "::1")) 421 (should (string-equal (file-remote-p "/[::1]:" 'host) "::1"))
401 (should (string-equal (file-remote-p "/[::1]:" 'localname) "")) 422 (should (string-equal (file-remote-p "/[::1]:" 'localname) ""))
423 (should (string-equal (file-remote-p "/[::1]:" 'hop) nil))
402 424
403 ;; Expand `tramp-default-method'. 425 ;; Expand `tramp-default-method'.
404 (should (string-equal 426 (should (string-equal
@@ -409,6 +431,7 @@ shall not contain a timeout."
409 (should (string-equal (file-remote-p "/user@[::1]:" 'user) "user")) 431 (should (string-equal (file-remote-p "/user@[::1]:" 'user) "user"))
410 (should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1")) 432 (should (string-equal (file-remote-p "/user@[::1]:" 'host) "::1"))
411 (should (string-equal (file-remote-p "/user@[::1]:" 'localname) "")) 433 (should (string-equal (file-remote-p "/user@[::1]:" 'localname) ""))
434 (should (string-equal (file-remote-p "/user@[::1]:" 'hop) nil))
412 435
413 ;; Expand `tramp-default-user'. 436 ;; Expand `tramp-default-user'.
414 (should (string-equal 437 (should (string-equal
@@ -419,6 +442,7 @@ shall not contain a timeout."
419 (file-remote-p "/method:[::1]:" 'user) "default-user")) 442 (file-remote-p "/method:[::1]:" 'user) "default-user"))
420 (should (string-equal (file-remote-p "/method:[::1]:" 'host) "::1")) 443 (should (string-equal (file-remote-p "/method:[::1]:" 'host) "::1"))
421 (should (string-equal (file-remote-p "/method:[::1]:" 'localname) "")) 444 (should (string-equal (file-remote-p "/method:[::1]:" 'localname) ""))
445 (should (string-equal (file-remote-p "/method:[::1]:" 'hop) nil))
422 446
423 ;; No expansion. 447 ;; No expansion.
424 (should (string-equal 448 (should (string-equal
@@ -430,6 +454,7 @@ shall not contain a timeout."
430 (should (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1")) 454 (should (string-equal (file-remote-p "/method:user@[::1]:" 'host) "::1"))
431 (should (string-equal 455 (should (string-equal
432 (file-remote-p "/method:user@[::1]:" 'localname) "")) 456 (file-remote-p "/method:user@[::1]:" 'localname) ""))
457 (should (string-equal (file-remote-p "/method:user@[::1]:" 'hop) nil))
433 458
434 ;; Local file name part. 459 ;; Local file name part.
435 (should (string-equal (file-remote-p "/host:/:" 'localname) "/:")) 460 (should (string-equal (file-remote-p "/host:/:" 'localname) "/:"))
@@ -444,7 +469,8 @@ shall not contain a timeout."
444 (should 469 (should
445 (string-equal 470 (string-equal
446 (file-remote-p "/method1:user1@host1|method2:user2@host2:/path/to/file") 471 (file-remote-p "/method1:user1@host1|method2:user2@host2:/path/to/file")
447 (format "/%s:%s@%s:" "method2" "user2" "host2"))) 472 (format "/%s:%s@%s|%s:%s@%s:"
473 "method1" "user1" "host1" "method2" "user2" "host2")))
448 (should 474 (should
449 (string-equal 475 (string-equal
450 (file-remote-p 476 (file-remote-p
@@ -465,12 +491,21 @@ shall not contain a timeout."
465 (file-remote-p 491 (file-remote-p
466 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'localname) 492 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'localname)
467 "/path/to/file")) 493 "/path/to/file"))
494 (should
495 (string-equal
496 (file-remote-p
497 "/method1:user1@host1|method2:user2@host2:/path/to/file" 'hop)
498 (format "%s:%s@%s|"
499 "method1" "user1" "host1")))
468 500
469 (should 501 (should
470 (string-equal 502 (string-equal
471 (file-remote-p 503 (file-remote-p
472 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file") 504 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file")
473 (format "/%s:%s@%s:" "method3" "user3" "host3"))) 505 (format "/%s:%s@%s|%s:%s@%s|%s:%s@%s:"
506 "method1" "user1" "host1"
507 "method2" "user2" "host2"
508 "method3" "user3" "host3")))
474 (should 509 (should
475 (string-equal 510 (string-equal
476 (file-remote-p 511 (file-remote-p
@@ -494,7 +529,14 @@ shall not contain a timeout."
494 (file-remote-p 529 (file-remote-p
495 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file" 530 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
496 'localname) 531 'localname)
497 "/path/to/file")))) 532 "/path/to/file"))
533 (should
534 (string-equal
535 (file-remote-p
536 "/method1:user1@host1|method2:user2@host2|method3:user3@host3:/path/to/file"
537 'hop)
538 (format "%s:%s@%s|%s:%s@%s|"
539 "method1" "user1" "host1" "method2" "user2" "host2")))))
498 540
499(ert-deftest tramp-test03-file-name-defaults () 541(ert-deftest tramp-test03-file-name-defaults ()
500 "Check default values for some methods." 542 "Check default values for some methods."
@@ -2168,11 +2210,7 @@ Since it unloads Tramp, it shall be the last test to run."
2168;; * Work on skipped tests. Make a comment, when it is impossible. 2210;; * Work on skipped tests. Make a comment, when it is impossible.
2169;; * Fix `tramp-test15-copy-directory' for `smb'. Using tar in a pipe 2211;; * Fix `tramp-test15-copy-directory' for `smb'. Using tar in a pipe
2170;; doesn't work well when an interactive password must be provided. 2212;; doesn't work well when an interactive password must be provided.
2171;; * Fix `tramp-test27-start-file-process' for `nc' and on MS 2213;; * Fix `tramp-test27-start-file-process' on MS Windows (`process-send-eof'?).
2172;; Windows (`process-send-eof'?).
2173;; * Fix `tramp-test31-special-characters' for `nc'.
2174;; * Fix `tramp-test32-utf8' for `nc'/`telnet' (when target is a dumb
2175;; busybox). Seems to be in `directory-files'.
2176;; * Fix Bug#16928. Set expected error of `tramp-test33-asynchronous-requests'. 2214;; * Fix Bug#16928. Set expected error of `tramp-test33-asynchronous-requests'.
2177;; * Fix `tramp-test35-unload' (Not all symbols are unbound). Set 2215;; * Fix `tramp-test35-unload' (Not all symbols are unbound). Set
2178;; expected error. 2216;; expected error.