diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2017-10-20 22:44:13 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2017-10-20 22:44:13 -0700 |
commit | 3155cb1585da7235145d76791feaf6170d8be0f1 (patch) | |
tree | 19b655867f27bb630b182f4bdb00a2e2d5ee6427 /lisp/net/tramp-sh.el | |
parent | cb29f41624e5163a0aea4bfc98591e683807a2f8 (diff) | |
parent | 11bd8aa24b347f75e674528dd1a94b0a4037105e (diff) | |
download | emacs-3155cb1585da7235145d76791feaf6170d8be0f1.tar.gz emacs-3155cb1585da7235145d76791feaf6170d8be0f1.tar.bz2 emacs-3155cb1585da7235145d76791feaf6170d8be0f1.zip |
Merge from origin/emacs-26
11bd8aa24b Fix flymake's loading of subr-x
b500e06f4d Fix Bug#28896
d815de017b Skip a Flymake test for old gcc versions
fd3d8610b2 Make :align-to account for display-line-numbers
831eafc8ae Augment Flymake API for third-party extensions
ddd547fada Improve treatment of Fortran's "class default"
234b1e3864 Flymake backends must check proc obsoleteness in source bu...
3ea6a4d4ba Skip an rsync test in tramp-tests.el
25f83fa7c5 ; Indentation fixes
4d578d432d On Windows default a frame's border width to zero (Bug#28873)
6f1dea5c74 Spelling fixes
b8433b0954 Use pop-to-buffer-same-window instead of switch-to-buffer
2f7163fb72 Fix the MSDOS build.
2551d28fe8 Fix line number display after 'widen'
dc8812829b Remove resizable attribute on macOS undecorated frames (bu...
b970a4a52a Fix handling of `border-width' in `frameset--restore-frame...
445e92658f Mention how to send CC to > 1 address in a bug report
8ca6fa585a Improve format-time-string doc
2e1b3522b8 Improve documentation of 'line-number-display-width'
5b6e59cfdb Implement vc-default-dir-extra-headers for vc-rcs
22adeca42a In NEWS give advice on use of `switch-to-buffer' (Bug#28645)
2c3e6f1ddc Dont update primary selection with winner-undo
b38724ab67 Work around ImageMagick bug 825
20cc68e871 Document rectangle-preview option more (Bug#27974)
a0b7b301dd Do not reject https://gnu.org in commit messages
fb4200a875 Fix Edebug spec for cl-defun (bug#24255)
db68cefe72 Fix errors in kmacro.el post-command-hook
c63b344c3d Fix range-error in image-dired.el
081d2187c4 Fix 'line-number-display-width' in hscrolled windows
16e85456e7 Fix error in tramp-smb-handle-insert-directory
613db8d35c Don't reject PBM header whitespace unnecessarily
3205b12a78 Fix regression in display of PPM images
1ca9ae7069 Require subr-x when compiling nnimap.el
de60992053 Fix ert-test finding by symbol (Bug#28849)
51615a8082 Don't remember old debugger window (Bug#17882)
5980de3727 Disable python native completion on w32 (Bug#28580)
616b4c5956 Let select-frame-by-name choose any frame when called from...
8eb3c01dbd * lisp/dired-aux.el (dired-create-directory): Doc fix.
325dfdae13 Avoid compilation warnings in optimized builds
f79382819c ; * src/composite.c (Fclear_composition_cache): Fix last c...
f95cd5cd70 Improve customization of arabic-shaper-ZWNJ-handling.
a7f154688d Improve customization type of 'mouse-drag-and-drop-region'
864734d112 ; Prefer https: to http: in GNU URLs
3c78960a47 Encourage https: in commit messages
def9715282 ; Cleanup of etc/NEWS
4e59ecc646 Fix wording in Elisp manual's child frames section (Bug#28...
eda9f5018c Another fix for C mode fontification of w32 source files
05aadd8990 Fix fontification of ALIGN_STACK functions
aa0c38f358 Make sure thread stack is properly aligned on MS-Windows
d7038020aa Do not under-align pseudovectors
ff33053012 Fix indentation bug in multi-line CSS selectors
8968be822e ; * etc/NEWS: Grammar and spelling fixes
716b84034d gnutls_mac_get_nonce_size has been added in gnutls 3.3
55e313f7be ; * CONTRIBUTE: More suggestions for using US English.
622c675648 * CONTRIBUTE: Suggest American English.
# Conflicts:
# etc/NEWS
# msdos/sed2v2.inp
Diffstat (limited to 'lisp/net/tramp-sh.el')
-rw-r--r-- | lisp/net/tramp-sh.el | 174 |
1 files changed, 90 insertions, 84 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index bdb7a132408..52a6b8fac0b 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -2039,96 +2039,102 @@ of `copy' and `rename'. FILENAME and NEWNAME must be absolute file names." (unless (memq op '(copy rename)) (error "Unknown operation `%s', must be `copy' or `rename'" op)) - (let ((t1 (tramp-tramp-file-p filename)) - (t2 (tramp-tramp-file-p newname)) - (length (tramp-compat-file-attribute-size - (file-attributes (file-truename filename)))) - (attributes (and preserve-extended-attributes - (apply 'file-extended-attributes (list filename))))) - (with-parsed-tramp-file-name (if t1 filename newname) nil - (when (and (not ok-if-already-exists) (file-exists-p newname)) - (tramp-error v 'file-already-exists newname)) - - (with-tramp-progress-reporter - v 0 (format "%s %s to %s" - (if (eq op 'copy) "Copying" "Renaming") - filename newname) + (if (file-directory-p filename) + (progn + (copy-directory filename newname keep-date t) + (when (eq op 'rename) (delete-directory filename 'recursive))) - (cond - ;; Both are Tramp files. - ((and t1 t2) - (with-parsed-tramp-file-name filename v1 - (with-parsed-tramp-file-name newname v2 - (cond - ;; Shortcut: if method, host, user are the same for - ;; both files, we invoke `cp' or `mv' on the remote - ;; host directly. - ((tramp-equal-remote filename newname) - (tramp-do-copy-or-rename-file-directly - op filename newname - ok-if-already-exists keep-date preserve-uid-gid)) - - ;; Try out-of-band operation. - ((and - (tramp-method-out-of-band-p v1 length) - (tramp-method-out-of-band-p v2 length)) - (tramp-do-copy-or-rename-file-out-of-band - op filename newname keep-date)) - - ;; No shortcut was possible. So we copy the file - ;; first. If the operation was `rename', we go back - ;; and delete the original file (if the copy was - ;; successful). The approach is simple-minded: we - ;; create a new buffer, insert the contents of the - ;; source file into it, then write out the buffer to - ;; the target file. The advantage is that it doesn't - ;; matter which file name handlers are used for the - ;; source and target file. - (t - (tramp-do-copy-or-rename-file-via-buffer - op filename newname keep-date)))))) - - ;; One file is a Tramp file, the other one is local. - ((or t1 t2) - (cond - ;; Fast track on local machine. - ((tramp-local-host-p v) - (tramp-do-copy-or-rename-file-directly - op filename newname - ok-if-already-exists keep-date preserve-uid-gid)) + (let ((t1 (tramp-tramp-file-p filename)) + (t2 (tramp-tramp-file-p newname)) + (length (tramp-compat-file-attribute-size + (file-attributes (file-truename filename)))) + (attributes (and preserve-extended-attributes + (apply 'file-extended-attributes (list filename))))) - ;; If the Tramp file has an out-of-band method, the - ;; corresponding copy-program can be invoked. - ((tramp-method-out-of-band-p v length) - (tramp-do-copy-or-rename-file-out-of-band - op filename newname keep-date)) + (with-parsed-tramp-file-name (if t1 filename newname) nil + (when (and (not ok-if-already-exists) (file-exists-p newname)) + (tramp-error v 'file-already-exists newname)) - ;; Use the inline method via a Tramp buffer. - (t (tramp-do-copy-or-rename-file-via-buffer - op filename newname keep-date)))) + (with-tramp-progress-reporter + v 0 (format "%s %s to %s" + (if (eq op 'copy) "Copying" "Renaming") + filename newname) - (t - ;; One of them must be a Tramp file. - (error "Tramp implementation says this cannot happen"))) + (cond + ;; Both are Tramp files. + ((and t1 t2) + (with-parsed-tramp-file-name filename v1 + (with-parsed-tramp-file-name newname v2 + (cond + ;; Shortcut: if method, host, user are the same for + ;; both files, we invoke `cp' or `mv' on the remote + ;; host directly. + ((tramp-equal-remote filename newname) + (tramp-do-copy-or-rename-file-directly + op filename newname + ok-if-already-exists keep-date preserve-uid-gid)) + + ;; Try out-of-band operation. + ((and + (tramp-method-out-of-band-p v1 length) + (tramp-method-out-of-band-p v2 length)) + (tramp-do-copy-or-rename-file-out-of-band + op filename newname keep-date)) + + ;; No shortcut was possible. So we copy the file + ;; first. If the operation was `rename', we go back + ;; and delete the original file (if the copy was + ;; successful). The approach is simple-minded: we + ;; create a new buffer, insert the contents of the + ;; source file into it, then write out the buffer to + ;; the target file. The advantage is that it doesn't + ;; matter which file name handlers are used for the + ;; source and target file. + (t + (tramp-do-copy-or-rename-file-via-buffer + op filename newname keep-date)))))) + + ;; One file is a Tramp file, the other one is local. + ((or t1 t2) + (cond + ;; Fast track on local machine. + ((tramp-local-host-p v) + (tramp-do-copy-or-rename-file-directly + op filename newname + ok-if-already-exists keep-date preserve-uid-gid)) + + ;; If the Tramp file has an out-of-band method, the + ;; corresponding copy-program can be invoked. + ((tramp-method-out-of-band-p v length) + (tramp-do-copy-or-rename-file-out-of-band + op filename newname keep-date)) + + ;; Use the inline method via a Tramp buffer. + (t (tramp-do-copy-or-rename-file-via-buffer + op filename newname keep-date)))) - ;; Handle `preserve-extended-attributes'. We ignore possible - ;; errors, because ACL strings could be incompatible. - (when attributes - (ignore-errors - (apply 'set-file-extended-attributes (list newname attributes)))) - - ;; In case of `rename', we must flush the cache of the source file. - (when (and t1 (eq op 'rename)) - (with-parsed-tramp-file-name filename v1 - (tramp-flush-file-property v1 (file-name-directory v1-localname)) - (tramp-flush-file-property v1 v1-localname))) - - ;; When newname did exist, we have wrong cached values. - (when t2 - (with-parsed-tramp-file-name newname v2 - (tramp-flush-file-property v2 (file-name-directory v2-localname)) - (tramp-flush-file-property v2 v2-localname))))))) + (t + ;; One of them must be a Tramp file. + (error "Tramp implementation says this cannot happen"))) + + ;; Handle `preserve-extended-attributes'. We ignore possible + ;; errors, because ACL strings could be incompatible. + (when attributes + (ignore-errors + (apply 'set-file-extended-attributes (list newname attributes)))) + + ;; In case of `rename', we must flush the cache of the source file. + (when (and t1 (eq op 'rename)) + (with-parsed-tramp-file-name filename v1 + (tramp-flush-file-property v1 (file-name-directory v1-localname)) + (tramp-flush-file-property v1 v1-localname))) + + ;; When newname did exist, we have wrong cached values. + (when t2 + (with-parsed-tramp-file-name newname v2 + (tramp-flush-file-property v2 (file-name-directory v2-localname)) + (tramp-flush-file-property v2 v2-localname)))))))) (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date) "Use an Emacs buffer to copy or rename a file. |