[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp/net tramp.el
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] emacs/lisp/net tramp.el |
Date: |
Tue, 28 Jul 2009 20:34:32 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Michael Albinus <albinus> 09/07/28 20:34:32
Modified files:
lisp/net : tramp.el
Log message:
* net/tramp.el (tramp-do-copy-or-rename-file): Add messages.
Simplify check for out-of-band methods.
(tramp-do-copy-or-rename-file-out-of-band): Allow both files to be
remote. Remove messages which are in `tramp-do-copy-or-rename-file'.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/net/tramp.el?cvsroot=emacs&r1=1.244&r2=1.245
Patches:
Index: tramp.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/net/tramp.el,v
retrieving revision 1.244
retrieving revision 1.245
diff -u -b -r1.244 -r1.245
--- tramp.el 16 Jul 2009 10:23:46 -0000 1.244
+++ tramp.el 28 Jul 2009 20:34:32 -0000 1.245
@@ -3118,6 +3118,9 @@
(tramp-error
v 'file-already-exists "File %s already exists" newname)))
+ (with-parsed-tramp-file-name (if t1 filename newname) nil
+ (tramp-message v 0 "Transferring %s to %s..." filename newname))
+
(prog1
(cond
;; Both are Tramp files.
@@ -3133,13 +3136,8 @@
op filename newname
ok-if-already-exists keep-date preserve-uid-gid))
- ;; If both source and target are Tramp files,
- ;; both are using the same copy-program, then we
- ;; can invoke rcp directly. Note that
- ;; default-directory should point to a local
- ;; directory if we want to invoke rcp.
- ((and (equal v1-method v2-method)
- (tramp-method-out-of-band-p v1)
+ ;; Try out-of-band operation.
+ ((and (tramp-method-out-of-band-p v1)
(> (nth 7 (file-attributes filename))
tramp-copy-size-limit))
(tramp-do-copy-or-rename-file-out-of-band
@@ -3192,7 +3190,10 @@
;; When newname did exist, we have wrong cached values.
(when t2
(with-parsed-tramp-file-name newname nil
- (tramp-flush-file-property v localname))))))
+ (tramp-flush-file-property v localname)))
+
+ (with-parsed-tramp-file-name (if t1 filename newname) nil
+ (tramp-message v 0 "Transferring %s to %s...done" filename newname)))))
(defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
"Use an Emacs buffer to copy or rename a file.
@@ -3376,14 +3377,28 @@
(defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date)
"Invoke rcp program to copy.
-One of FILENAME and NEWNAME must be a Tramp name, the other must
-be a local filename. The method used must be an out-of-band method."
+The method used must be an out-of-band method."
(let ((t1 (tramp-tramp-file-p filename))
(t2 (tramp-tramp-file-p newname))
copy-program copy-args copy-keep-date port spec
source target)
(with-parsed-tramp-file-name (if t1 filename newname) nil
+ (if (and t1 t2)
+
+ ;; Both are Tramp files. We shall optimize it, when the
+ ;; methods for filename and newname are the same.
+ (let ((tmpfile (tramp-compat-make-temp-file localname)))
+ (unwind-protect
+ (progn
+ (tramp-do-copy-or-rename-file-out-of-band
+ op filename tmpfile keep-date)
+ (tramp-do-copy-or-rename-file-out-of-band
+ 'rename tmpfile newname keep-date))
+ ;; Save exit.
+ (condition-case nil
+ (delete-file tmpfile)
+ (error))))
;; Expand hops. Might be necessary for gateway methods.
(setq v (car (tramp-compute-multi-hops v)))
@@ -3414,8 +3429,9 @@
(mapcar
'(lambda (x)
(setq
+ x
;; " " is indication for keep-date argument.
- x (delete " " (mapcar '(lambda (y) (format-spec y spec)) x)))
+ (delete " " (mapcar '(lambda (y) (format-spec y spec)) x)))
(unless (member "" x) (mapconcat 'identity x " ")))
(tramp-get-method-parameter method 'tramp-copy-args))))
@@ -3427,8 +3443,6 @@
(tramp-error
v 'file-error "Cannot find copy program: %s" copy-program))
- (tramp-message v 0 "Transferring %s to %s..." filename newname)
-
(unwind-protect
(with-temp-buffer
;; The default directory must be remote.
@@ -3463,8 +3477,6 @@
(tramp-set-connection-property v "process-name" nil)
(tramp-set-connection-property v "process-buffer" nil))
- (tramp-message v 0 "Transferring %s to %s...done" filename newname)
-
;; Handle KEEP-DATE argument.
(when (and keep-date (not copy-keep-date))
(set-file-times newname (nth 5 (file-attributes filename))))
@@ -3475,7 +3487,7 @@
;; If the operation was `rename', delete the original file.
(unless (eq op 'copy)
- (delete-file filename))))
+ (delete-file filename)))))
(defun tramp-handle-make-directory (dir &optional parents)
"Like `make-directory' for Tramp files."
@@ -7855,6 +7867,7 @@
;; tramp-server-local-variable-alist) to define any such variables
;; that they need to, which would then be let bound as appropriate
;; in tramp functions. (Jason Rumney)
+;; * Optimize out-of-band copying, when both methods are scp-like.
;; Functions for file-name-handler-alist:
;; diff-latest-backup-file -- in diff.el