aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2009-10-05 11:30:52 +0000
committerMichael Albinus2009-10-05 11:30:52 +0000
commit263c02efe258e230b4d820f03422959b05368702 (patch)
tree1362fe74cb1fedae76beb71213d53949cde4045b
parent804543b5c06bcb56640d2239a14032fea5b8aa4a (diff)
downloademacs-263c02efe258e230b4d820f03422959b05368702.tar.gz
emacs-263c02efe258e230b4d820f03422959b05368702.zip
* net/tramp.el (tramp-verbose): Fix docstring.
(tramp-methods): Add recursive option to `tramp-copy-args'. Add `tramp-copy-recursive'. Valid for "rcp", "scp", "scp1", "scp2", "scp1_old", "scp2_old", "rsync", "rsyncc". (tramp-default-method): Check also for `auth-source-user-or-password'. (tramp-file-name-handler-alist, tramp-file-name-for-operation): Add handler for `copy-directory'. (tramp-handle-copy-directory): New defun. (tramp-do-copy-or-rename-file-out-of-band): Handle directory case. (tramp-handle-start-file-process): Raise an error when PROGRAM is nil. Optimize sent command.
-rw-r--r--lisp/ChangeLog13
-rw-r--r--lisp/net/tramp.el112
2 files changed, 94 insertions, 31 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e4a94b55c92..3dba231e6c2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -4,6 +4,19 @@
4 (delete-directory): Use it. 4 (delete-directory): Use it.
5 (copy-directory): Use it. Remove parameter PRESERVE-UID-GID. 5 (copy-directory): Use it. Remove parameter PRESERVE-UID-GID.
6 6
7 * net/tramp.el (tramp-verbose): Fix docstring.
8 (tramp-methods): Add recursive option to `tramp-copy-args'. Add
9 `tramp-copy-recursive'. Valid for "rcp", "scp", "scp1", "scp2",
10 "scp1_old", "scp2_old", "rsync", "rsyncc".
11 (tramp-default-method): Check also for
12 `auth-source-user-or-password'.
13 (tramp-file-name-handler-alist, tramp-file-name-for-operation):
14 Add handler for `copy-directory'.
15 (tramp-handle-copy-directory): New defun.
16 (tramp-do-copy-or-rename-file-out-of-band): Handle directory case.
17 (tramp-handle-start-file-process): Raise an error when PROGRAM is
18 nil. Optimize sent command.
19
72009-10-05 Stefan Monnier <monnier@iro.umontreal.ca> 202009-10-05 Stefan Monnier <monnier@iro.umontreal.ca>
8 21
9 * calendar/diary-lib.el (diary-show-all-entries): Re-fit the calendar 22 * calendar/diary-lib.el (diary-show-all-entries): Re-fit the calendar
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index f3c61e942be..9be6ea8a0df 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -187,7 +187,7 @@ If it is set to nil, all remote file names are used literally."
187 :type 'boolean) 187 :type 'boolean)
188 188
189(defcustom tramp-verbose 3 189(defcustom tramp-verbose 3
190 "*Verbosity level for Tramp. 190 "*Verbosity level for Tramp messages.
191Any level x includes messages for all levels 1 .. x-1. The levels are 191Any level x includes messages for all levels 1 .. x-1. The levels are
192 192
193 0 silent (no tramp messages at all) 193 0 silent (no tramp messages at all)
@@ -203,7 +203,7 @@ Any level x includes messages for all levels 1 .. x-1. The levels are
203 :group 'tramp 203 :group 'tramp
204 :type 'integer) 204 :type 'integer)
205 205
206;; Emacs case 206;; Emacs case.
207(eval-and-compile 207(eval-and-compile
208 (when (boundp 'backup-directory-alist) 208 (when (boundp 'backup-directory-alist)
209 (defcustom tramp-backup-directory-alist nil 209 (defcustom tramp-backup-directory-alist nil
@@ -302,16 +302,19 @@ files conditionalize this setup based on the TERM environment variable."
302 (tramp-login-args (("%h") ("-l" "%u"))) 302 (tramp-login-args (("%h") ("-l" "%u")))
303 (tramp-remote-sh "/bin/sh") 303 (tramp-remote-sh "/bin/sh")
304 (tramp-copy-program "rcp") 304 (tramp-copy-program "rcp")
305 (tramp-copy-args (("-p" "%k"))) 305 (tramp-copy-args (("-p" "%k") ("-r")))
306 (tramp-copy-keep-date t) 306 (tramp-copy-keep-date t)
307 (tramp-copy-recursive t)
307 (tramp-password-end-of-line nil)) 308 (tramp-password-end-of-line nil))
308 ("scp" (tramp-login-program "ssh") 309 ("scp" (tramp-login-program "ssh")
309 (tramp-login-args (("%h") ("-l" "%u") ("-p" "%p") ("-q") 310 (tramp-login-args (("%h") ("-l" "%u") ("-p" "%p") ("-q")
310 ("-e" "none"))) 311 ("-e" "none")))
311 (tramp-remote-sh "/bin/sh") 312 (tramp-remote-sh "/bin/sh")
312 (tramp-copy-program "scp") 313 (tramp-copy-program "scp")
313 (tramp-copy-args (("-P" "%p") ("-p" "%k") ("-q"))) 314 (tramp-copy-args (("-P" "%p") ("-p" "%k")
315 ("-q") ("-r")))
314 (tramp-copy-keep-date t) 316 (tramp-copy-keep-date t)
317 (tramp-copy-recursive t)
315 (tramp-password-end-of-line nil) 318 (tramp-password-end-of-line nil)
316 (tramp-gw-args (("-o" 319 (tramp-gw-args (("-o"
317 "GlobalKnownHostsFile=/dev/null") 320 "GlobalKnownHostsFile=/dev/null")
@@ -324,8 +327,9 @@ files conditionalize this setup based on the TERM environment variable."
324 (tramp-remote-sh "/bin/sh") 327 (tramp-remote-sh "/bin/sh")
325 (tramp-copy-program "scp") 328 (tramp-copy-program "scp")
326 (tramp-copy-args (("-1") ("-P" "%p") ("-p" "%k") 329 (tramp-copy-args (("-1") ("-P" "%p") ("-p" "%k")
327 ("-q"))) 330 ("-q") ("-r")))
328 (tramp-copy-keep-date t) 331 (tramp-copy-keep-date t)
332 (tramp-copy-recursive t)
329 (tramp-password-end-of-line nil) 333 (tramp-password-end-of-line nil)
330 (tramp-gw-args (("-o" 334 (tramp-gw-args (("-o"
331 "GlobalKnownHostsFile=/dev/null") 335 "GlobalKnownHostsFile=/dev/null")
@@ -338,8 +342,9 @@ files conditionalize this setup based on the TERM environment variable."
338 (tramp-remote-sh "/bin/sh") 342 (tramp-remote-sh "/bin/sh")
339 (tramp-copy-program "scp") 343 (tramp-copy-program "scp")
340 (tramp-copy-args (("-2") ("-P" "%p") ("-p" "%k") 344 (tramp-copy-args (("-2") ("-P" "%p") ("-p" "%k")
341 ("-q"))) 345 ("-q") ("-r")))
342 (tramp-copy-keep-date t) 346 (tramp-copy-keep-date t)
347 (tramp-copy-recursive t)
343 (tramp-password-end-of-line nil) 348 (tramp-password-end-of-line nil)
344 (tramp-gw-args (("-o" 349 (tramp-gw-args (("-o"
345 "GlobalKnownHostsFile=/dev/null") 350 "GlobalKnownHostsFile=/dev/null")
@@ -352,8 +357,9 @@ files conditionalize this setup based on the TERM environment variable."
352 ("-e" "none"))) 357 ("-e" "none")))
353 (tramp-remote-sh "/bin/sh") 358 (tramp-remote-sh "/bin/sh")
354 (tramp-copy-program "scp1") 359 (tramp-copy-program "scp1")
355 (tramp-copy-args (("-p" "%k"))) 360 (tramp-copy-args (("-p" "%k") ("-r")))
356 (tramp-copy-keep-date t) 361 (tramp-copy-keep-date t)
362 (tramp-copy-recursive t)
357 (tramp-password-end-of-line nil)) 363 (tramp-password-end-of-line nil))
358 ("scp2_old" 364 ("scp2_old"
359 (tramp-login-program "ssh2") 365 (tramp-login-program "ssh2")
@@ -361,8 +367,9 @@ files conditionalize this setup based on the TERM environment variable."
361 ("-e" "none"))) 367 ("-e" "none")))
362 (tramp-remote-sh "/bin/sh") 368 (tramp-remote-sh "/bin/sh")
363 (tramp-copy-program "scp2") 369 (tramp-copy-program "scp2")
364 (tramp-copy-args (("-p" "%k"))) 370 (tramp-copy-args (("-p" "%k") ("-r")))
365 (tramp-copy-keep-date t) 371 (tramp-copy-keep-date t)
372 (tramp-copy-recursive t)
366 (tramp-password-end-of-line nil)) 373 (tramp-password-end-of-line nil))
367 ("sftp" (tramp-login-program "ssh") 374 ("sftp" (tramp-login-program "ssh")
368 (tramp-login-args (("%h") ("-l" "%u") ("-p" "%p") 375 (tramp-login-args (("%h") ("-l" "%u") ("-p" "%p")
@@ -377,23 +384,26 @@ files conditionalize this setup based on the TERM environment variable."
377 ("-e" "none"))) 384 ("-e" "none")))
378 (tramp-remote-sh "/bin/sh") 385 (tramp-remote-sh "/bin/sh")
379 (tramp-copy-program "rsync") 386 (tramp-copy-program "rsync")
380 (tramp-copy-args (("-e" "ssh") ("-t" "%k"))) 387 (tramp-copy-args (("-e" "ssh") ("-t" "%k") ("-r")))
381 (tramp-copy-keep-date t) 388 (tramp-copy-keep-date t)
389 (tramp-copy-recursive t)
382 (tramp-password-end-of-line nil)) 390 (tramp-password-end-of-line nil))
383 ("rsyncc" (tramp-login-program "ssh") 391 ("rsyncc"
392 (tramp-login-program "ssh")
384 (tramp-login-args (("%h") ("-l" "%u") ("-p" "%p") 393 (tramp-login-args (("%h") ("-l" "%u") ("-p" "%p")
385 ("-o" "ControlPath=%t.%%r@%%h:%%p") 394 ("-o" "ControlPath=%t.%%r@%%h:%%p")
386 ("-o" "ControlMaster=yes") 395 ("-o" "ControlMaster=yes")
387 ("-e" "none"))) 396 ("-e" "none")))
388 (tramp-remote-sh "/bin/sh") 397 (tramp-remote-sh "/bin/sh")
389 (tramp-copy-program "rsync") 398 (tramp-copy-program "rsync")
390 (tramp-copy-args (("-t" "%k"))) 399 (tramp-copy-args (("-t" "%k") ("-r")))
391 (tramp-copy-env (("RSYNC_RSH") 400 (tramp-copy-env (("RSYNC_RSH")
392 (,(concat 401 (,(concat
393 "ssh" 402 "ssh"
394 " -o ControlPath=%t.%%r@%%h:%%p" 403 " -o ControlPath=%t.%%r@%%h:%%p"
395 " -o ControlMaster=auto")))) 404 " -o ControlMaster=auto"))))
396 (tramp-copy-keep-date t) 405 (tramp-copy-keep-date t)
406 (tramp-copy-recursive t)
397 (tramp-password-end-of-line nil)) 407 (tramp-password-end-of-line nil))
398 ("remcp" (tramp-login-program "remsh") 408 ("remcp" (tramp-login-program "remsh")
399 (tramp-login-args (("%h") ("-l" "%u"))) 409 (tramp-login-args (("%h") ("-l" "%u")))
@@ -694,15 +704,16 @@ useful only in combination with `tramp-default-proxies-alist'.")
694 ;; more performant for large files, and it hasn't too serious delays 704 ;; more performant for large files, and it hasn't too serious delays
695 ;; for small files. But it must be ensured that there aren't 705 ;; for small files. But it must be ensured that there aren't
696 ;; permanent password queries. Either a password agent like 706 ;; permanent password queries. Either a password agent like
697 ;; "ssh-agent" or "Pageant" shall run, or the optional password.el 707 ;; "ssh-agent" or "Pageant" shall run, or the optional
698 ;; package shall be active for password caching. "scpc" would be 708 ;; password-cache.el or auth-sources.el packages shall be active for
699 ;; another good choice because of the "ControlMaster" option, but 709 ;; password caching. "scpc" would be another good choice because of
700 ;; this is a more modern alternative in OpenSSH 4, which cannot be 710 ;; the "ControlMaster" option, but this is a more modern alternative
701 ;; taken as default. 711 ;; in OpenSSH 4, which cannot be taken as default.
702 (cond 712 (cond
703 ;; PuTTY is installed. 713 ;; PuTTY is installed.
704 ((executable-find "pscp") 714 ((executable-find "pscp")
705 (if (or (fboundp 'password-read) 715 (if (or (fboundp 'password-read)
716 (fboundp 'auth-source-user-or-password)
706 ;; Pageant is running. 717 ;; Pageant is running.
707 (tramp-compat-process-running-p "Pageant")) 718 (tramp-compat-process-running-p "Pageant"))
708 "pscp" 719 "pscp"
@@ -710,6 +721,7 @@ useful only in combination with `tramp-default-proxies-alist'.")
710 ;; There is an ssh installation. 721 ;; There is an ssh installation.
711 ((executable-find "scp") 722 ((executable-find "scp")
712 (if (or (fboundp 'password-read) 723 (if (or (fboundp 'password-read)
724 (fboundp 'auth-source-user-or-password)
713 ;; ssh-agent is running. 725 ;; ssh-agent is running.
714 (getenv "SSH_AUTH_SOCK") 726 (getenv "SSH_AUTH_SOCK")
715 (getenv "SSH_AGENT_PID")) 727 (getenv "SSH_AGENT_PID"))
@@ -1881,6 +1893,7 @@ This is used to map a mode number to a permission string.")
1881 (file-name-completion . tramp-handle-file-name-completion) 1893 (file-name-completion . tramp-handle-file-name-completion)
1882 (add-name-to-file . tramp-handle-add-name-to-file) 1894 (add-name-to-file . tramp-handle-add-name-to-file)
1883 (copy-file . tramp-handle-copy-file) 1895 (copy-file . tramp-handle-copy-file)
1896 (copy-directory . tramp-handle-copy-directory)
1884 (rename-file . tramp-handle-rename-file) 1897 (rename-file . tramp-handle-rename-file)
1885 (set-file-modes . tramp-handle-set-file-modes) 1898 (set-file-modes . tramp-handle-set-file-modes)
1886 (set-file-times . tramp-handle-set-file-times) 1899 (set-file-times . tramp-handle-set-file-times)
@@ -3159,6 +3172,35 @@ value of `default-file-modes', without execute permissions."
3159 (tramp-run-real-handler 3172 (tramp-run-real-handler
3160 'copy-file (list filename newname ok-if-already-exists keep-date))))) 3173 'copy-file (list filename newname ok-if-already-exists keep-date)))))
3161 3174
3175(defun tramp-handle-copy-directory (dirname newname &optional keep-date parents)
3176 "Like `copy-directory' for Tramp files."
3177 (let ((t1 (tramp-tramp-file-p dirname))
3178 (t2 (tramp-tramp-file-p newname)))
3179 (with-parsed-tramp-file-name (if t1 dirname newname) nil
3180 (if (and (tramp-get-method-parameter method 'tramp-copy-recursive)
3181 ;; When DIRNAME and NEWNAME are remote, they must have
3182 ;; the same method.
3183 (or (null t1) (null t2)
3184 (string-equal (file-remote-p dirname 'method)
3185 (file-remote-p newname 'method))))
3186 ;; scp or rsync DTRT.
3187 (progn
3188 (setq dirname (directory-file-name (expand-file-name dirname))
3189 newname (directory-file-name (expand-file-name newname)))
3190 (if (and (file-directory-p newname)
3191 (not (string-equal (file-name-nondirectory dirname)
3192 (file-name-nondirectory newname))))
3193 (setq newname
3194 (expand-file-name
3195 (file-name-nondirectory dirname) newname)))
3196 (if (not (file-directory-p (file-name-directory newname)))
3197 (make-directory (file-name-directory newname) parents))
3198 (tramp-do-copy-or-rename-file-out-of-band
3199 'copy dirname newname keep-date))
3200 ;; We must do it file-wise.
3201 (tramp-run-real-handler
3202 'copy-directory (list dirname newname keep-date parents))))))
3203
3162(defun tramp-handle-rename-file 3204(defun tramp-handle-rename-file
3163 (filename newname &optional ok-if-already-exists) 3205 (filename newname &optional ok-if-already-exists)
3164 "Like `rename-file' for Tramp files." 3206 "Like `rename-file' for Tramp files."
@@ -3484,7 +3526,14 @@ The method used must be an out-of-band method."
3484 3526
3485 ;; Check which ones of source and target are Tramp files. 3527 ;; Check which ones of source and target are Tramp files.
3486 (setq source (if t1 (tramp-make-copy-program-file-name v) filename) 3528 (setq source (if t1 (tramp-make-copy-program-file-name v) filename)
3487 target (if t2 (tramp-make-copy-program-file-name v) newname)) 3529 target (funcall
3530 (if (and (file-directory-p filename)
3531 (string-equal
3532 (file-name-nondirectory filename)
3533 (file-name-nondirectory newname)))
3534 'file-name-directory
3535 'identity)
3536 (if t2 (tramp-make-copy-program-file-name v) newname)))
3488 3537
3489 ;; Check for port number. Until now, there's no need for handling 3538 ;; Check for port number. Until now, there's no need for handling
3490 ;; like method, user, host. 3539 ;; like method, user, host.
@@ -3950,9 +3999,16 @@ beginning of local filename are not substituted."
3950;; connection has been setup. 3999;; connection has been setup.
3951(defun tramp-handle-start-file-process (name buffer program &rest args) 4000(defun tramp-handle-start-file-process (name buffer program &rest args)
3952 "Like `start-file-process' for Tramp files." 4001 "Like `start-file-process' for Tramp files."
4002 (unless (stringp program)
4003 (tramp-error
4004 v 'file-error "pty association is not supported for `%s'" name))
3953 (with-parsed-tramp-file-name default-directory nil 4005 (with-parsed-tramp-file-name default-directory nil
3954 (unwind-protect 4006 (unwind-protect
3955 (let ((name1 name) 4007 (let ((command (format "cd %s; exec %s"
4008 (tramp-shell-quote-argument localname)
4009 (mapconcat 'tramp-shell-quote-argument
4010 (cons program args) " ")))
4011 (name1 name)
3956 (i 0)) 4012 (i 0))
3957 (unless buffer 4013 (unless buffer
3958 ;; BUFFER can be nil. We use a temporary buffer. 4014 ;; BUFFER can be nil. We use a temporary buffer.
@@ -3971,17 +4027,9 @@ beginning of local filename are not substituted."
3971 (with-current-buffer (tramp-get-connection-buffer v) 4027 (with-current-buffer (tramp-get-connection-buffer v)
3972 (clear-visited-file-modtime) 4028 (clear-visited-file-modtime)
3973 (narrow-to-region (point-max) (point-max))) 4029 (narrow-to-region (point-max) (point-max)))
3974 ;; Goto working directory. `tramp-send-command' opens a new 4030 ;; Send the command. `tramp-send-command' opens a new
3975 ;; connection. 4031 ;; connection.
3976 (tramp-send-command 4032 (tramp-send-command v command nil t) ; nooutput
3977 v (format "cd %s" (tramp-shell-quote-argument localname)))
3978 ;; Send the command.
3979 (tramp-send-command
3980 v
3981 (format "exec %s"
3982 (mapconcat 'tramp-shell-quote-argument
3983 (cons program args) " "))
3984 nil t) ; nooutput
3985 ;; Set query flag for this process. 4033 ;; Set query flag for this process.
3986 (tramp-set-process-query-on-exit-flag 4034 (tramp-set-process-query-on-exit-flag
3987 (tramp-get-connection-process v) t) 4035 (tramp-get-connection-process v) t)
@@ -4091,6 +4139,7 @@ beginning of local filename are not substituted."
4091 (unless ret (setq ret (tramp-send-command-and-check v nil))) 4139 (unless ret (setq ret (tramp-send-command-and-check v nil)))
4092 ;; Provide error file. 4140 ;; Provide error file.
4093 (when tmpstderr (rename-file tmpstderr (cadr destination) t)) 4141 (when tmpstderr (rename-file tmpstderr (cadr destination) t))
4142
4094 ;; Cleanup. We remove all file cache values for the connection, 4143 ;; Cleanup. We remove all file cache values for the connection,
4095 ;; because the remote process could have changed them. 4144 ;; because the remote process could have changed them.
4096 (when tmpinput (delete-file tmpinput)) 4145 (when tmpinput (delete-file tmpinput))
@@ -4892,6 +4941,8 @@ ARGS are the arguments OPERATION has been called with."
4892 (list 'add-name-to-file 'copy-file 'expand-file-name 4941 (list 'add-name-to-file 'copy-file 'expand-file-name
4893 'file-name-all-completions 'file-name-completion 4942 'file-name-all-completions 'file-name-completion
4894 'file-newer-than-file-p 'make-symbolic-link 'rename-file 4943 'file-newer-than-file-p 'make-symbolic-link 'rename-file
4944 ; Emacs 23 only
4945 'copy-directory
4895 ; XEmacs only 4946 ; XEmacs only
4896 'dired-make-relative-symlink 4947 'dired-make-relative-symlink
4897 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail)) 4948 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail))
@@ -6116,7 +6167,7 @@ The terminal type can be configured with `tramp-terminal-type'."
6116 6167
6117(defun tramp-process-actions (proc vec actions &optional timeout) 6168(defun tramp-process-actions (proc vec actions &optional timeout)
6118 "Perform actions until success or TIMEOUT." 6169 "Perform actions until success or TIMEOUT."
6119 ;; Enable auth-sorce and password-cache. 6170 ;; Enable auth-source and password-cache.
6120 (tramp-set-connection-property proc "first-password-request" t) 6171 (tramp-set-connection-property proc "first-password-request" t)
6121 (let (exit) 6172 (let (exit)
6122 (while (not exit) 6173 (while (not exit)
@@ -8016,8 +8067,6 @@ Only works for Bourne-like shells."
8016;; * Provide a local cache of old versions of remote files for the rsync 8067;; * Provide a local cache of old versions of remote files for the rsync
8017;; transfer method to use. (Greg Stark) 8068;; transfer method to use. (Greg Stark)
8018;; * Remove unneeded parameters from methods. 8069;; * Remove unneeded parameters from methods.
8019;; * Invoke rsync once for copying a whole directory hierarchy.
8020;; (Francesco Potortì)
8021;; * Make it work for different encodings, and for different file name 8070;; * Make it work for different encodings, and for different file name
8022;; encodings, too. (Daniel Pittman) 8071;; encodings, too. (Daniel Pittman)
8023;; * Progress reports while copying files. (Michael Kifer) 8072;; * Progress reports while copying files. (Michael Kifer)
@@ -8079,6 +8128,7 @@ Only works for Bourne-like shells."
8079;; rsync). 8128;; rsync).
8080;; * Keep a second connection open for out-of-band methods like scp or 8129;; * Keep a second connection open for out-of-band methods like scp or
8081;; rsync. 8130;; rsync.
8131;; * Support ptys in `tramp-handle-start-file-process'.
8082 8132
8083;; Functions for file-name-handler-alist: 8133;; Functions for file-name-handler-alist:
8084;; diff-latest-backup-file -- in diff.el 8134;; diff-latest-backup-file -- in diff.el