aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2009-09-02 11:13:42 +0000
committerMichael Albinus2009-09-02 11:13:42 +0000
commit7f49fe463d55007ff962d9fe217add604921fba8 (patch)
treee71ad12c455e105649f7296f91e85170e1f70354
parent1a727c75ac2918b0e82f69fac645f34af7fa93b2 (diff)
downloademacs-7f49fe463d55007ff962d9fe217add604921fba8.tar.gz
emacs-7f49fe463d55007ff962d9fe217add604921fba8.zip
* net/tramp.el (tramp-handle-file-attributes-with-ls)
(tramp-do-file-attributes-with-perl) (tramp-do-file-attributes-with-stat): Rename from `tramp-handle-file-attributes-with-*'. (tramp-handle-file-attributes): Use them. (tramp-do-directory-files-and-attributes-with-perl) (tramp-do-directory-files-and-attributes-with-stat): Rename from `tramp-handle-directory-files-and-attributes-with-*'. (tramp-handle-directory-files-and-attributes): Use them. (tramp-method-out-of-band-p): Additional parameter SIZE. (tramp-do-copy-or-rename-file, tramp-handle-file-local-copy) (tramp-handle-write-region): Use it. (tramp-handle-insert-directory): Use "?\ " for compatibility reasons. (tramp-handle-vc-registered): Check, whether the first run did return files to be tested. (tramp-advice-make-auto-save-file-name): Do not call directly `tramp-handle-make-auto-save-file-name', because this would bypass the locking mechanism.
-rw-r--r--lisp/net/tramp.el146
1 files changed, 70 insertions, 76 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 1b389422296..2586542b656 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2504,21 +2504,18 @@ target of the symlink differ."
2504 (let ((last-coding-system-used last-coding-system-used)) 2504 (let ((last-coding-system-used last-coding-system-used))
2505 (with-parsed-tramp-file-name (expand-file-name filename) nil 2505 (with-parsed-tramp-file-name (expand-file-name filename) nil
2506 (with-file-property v localname (format "file-attributes-%s" id-format) 2506 (with-file-property v localname (format "file-attributes-%s" id-format)
2507 (when (file-exists-p filename) 2507 (save-excursion
2508 ;; file exists, find out stuff 2508 (tramp-convert-file-attributes
2509 (save-excursion 2509 v
2510 (tramp-convert-file-attributes 2510 (cond
2511 v 2511 ((tramp-get-remote-stat v)
2512 (if (tramp-get-remote-stat v) 2512 (tramp-do-file-attributes-with-stat v localname id-format))
2513 (tramp-handle-file-attributes-with-stat 2513 ((tramp-get-remote-perl v)
2514 v localname id-format) 2514 (tramp-do-file-attributes-with-perl v localname id-format))
2515 (if (tramp-get-remote-perl v) 2515 (t
2516 (tramp-handle-file-attributes-with-perl 2516 (tramp-do-file-attributes-with-ls v localname id-format)))))))))
2517 v localname id-format) 2517
2518 (tramp-handle-file-attributes-with-ls 2518(defun tramp-do-file-attributes-with-ls (vec localname &optional id-format)
2519 v localname id-format))))))))))
2520
2521(defun tramp-handle-file-attributes-with-ls (vec localname &optional id-format)
2522 "Implement `file-attributes' for Tramp files using the ls(1) command." 2519 "Implement `file-attributes' for Tramp files using the ls(1) command."
2523 (let (symlinkp dirp 2520 (let (symlinkp dirp
2524 res-inode res-filemodes res-numlinks 2521 res-inode res-filemodes res-numlinks
@@ -2603,7 +2600,7 @@ target of the symlink differ."
2603 -1 2600 -1
2604 )))) 2601 ))))
2605 2602
2606(defun tramp-handle-file-attributes-with-perl 2603(defun tramp-do-file-attributes-with-perl
2607 (vec localname &optional id-format) 2604 (vec localname &optional id-format)
2608 "Implement `file-attributes' for Tramp files using a Perl script." 2605 "Implement `file-attributes' for Tramp files using a Perl script."
2609 (tramp-message vec 5 "file attributes with perl: %s" localname) 2606 (tramp-message vec 5 "file attributes with perl: %s" localname)
@@ -2614,7 +2611,7 @@ target of the symlink differ."
2614 (format "tramp_perl_file_attributes %s %s" 2611 (format "tramp_perl_file_attributes %s %s"
2615 (tramp-shell-quote-argument localname) id-format))) 2612 (tramp-shell-quote-argument localname) id-format)))
2616 2613
2617(defun tramp-handle-file-attributes-with-stat 2614(defun tramp-do-file-attributes-with-stat
2618 (vec localname &optional id-format) 2615 (vec localname &optional id-format)
2619 "Implement `file-attributes' for Tramp files using stat(1) command." 2616 "Implement `file-attributes' for Tramp files using stat(1) command."
2620 (tramp-message vec 5 "file attributes with stat: %s" localname) 2617 (tramp-message vec 5 "file attributes with stat: %s" localname)
@@ -2643,7 +2640,7 @@ target of the symlink differ."
2643 (when (boundp 'last-coding-system-used) 2640 (when (boundp 'last-coding-system-used)
2644 (setq coding-system-used (symbol-value 'last-coding-system-used))) 2641 (setq coding-system-used (symbol-value 'last-coding-system-used)))
2645 ;; We use '(0 0) as a don't-know value. See also 2642 ;; We use '(0 0) as a don't-know value. See also
2646 ;; `tramp-handle-file-attributes-with-ls'. 2643 ;; `tramp-do-file-attributes-with-ls'.
2647 (if (not (equal modtime '(0 0))) 2644 (if (not (equal modtime '(0 0)))
2648 (tramp-run-real-handler 'set-visited-file-modtime (list modtime)) 2645 (tramp-run-real-handler 'set-visited-file-modtime (list modtime))
2649 (progn 2646 (progn
@@ -2968,12 +2965,13 @@ value of `default-file-modes', without execute permissions."
2968 (lambda (x) 2965 (lambda (x)
2969 (cons (car x) 2966 (cons (car x)
2970 (tramp-convert-file-attributes v (cdr x)))) 2967 (tramp-convert-file-attributes v (cdr x))))
2971 (if (tramp-get-remote-stat v) 2968 (cond
2972 (tramp-handle-directory-files-and-attributes-with-stat 2969 ((tramp-get-remote-stat v)
2973 v localname id-format) 2970 (tramp-do-directory-files-and-attributes-with-stat
2974 (if (tramp-get-remote-perl v) 2971 v localname id-format))
2975 (tramp-handle-directory-files-and-attributes-with-perl 2972 ((tramp-get-remote-perl v)
2976 v localname id-format))))))))) 2973 (tramp-do-directory-files-and-attributes-with-perl
2974 v localname id-format)))))))))
2977 result item) 2975 result item)
2978 2976
2979 (while temp 2977 (while temp
@@ -2987,7 +2985,7 @@ value of `default-file-modes', without execute permissions."
2987 result 2985 result
2988 (sort result (lambda (x y) (string< (car x) (car y)))))))) 2986 (sort result (lambda (x y) (string< (car x) (car y))))))))
2989 2987
2990(defun tramp-handle-directory-files-and-attributes-with-perl 2988(defun tramp-do-directory-files-and-attributes-with-perl
2991 (vec localname &optional id-format) 2989 (vec localname &optional id-format)
2992 "Implement `directory-files-and-attributes' for Tramp files using a Perl script." 2990 "Implement `directory-files-and-attributes' for Tramp files using a Perl script."
2993 (tramp-message vec 5 "directory-files-and-attributes with perl: %s" localname) 2991 (tramp-message vec 5 "directory-files-and-attributes with perl: %s" localname)
@@ -3002,7 +3000,7 @@ value of `default-file-modes', without execute permissions."
3002 (when (stringp object) (tramp-error vec 'file-error object)) 3000 (when (stringp object) (tramp-error vec 'file-error object))
3003 object)) 3001 object))
3004 3002
3005(defun tramp-handle-directory-files-and-attributes-with-stat 3003(defun tramp-do-directory-files-and-attributes-with-stat
3006 (vec localname &optional id-format) 3004 (vec localname &optional id-format)
3007 "Implement `directory-files-and-attributes' for Tramp files using stat(1) command." 3005 "Implement `directory-files-and-attributes' for Tramp files using stat(1) command."
3008 (tramp-message vec 5 "directory-files-and-attributes with stat: %s" localname) 3006 (tramp-message vec 5 "directory-files-and-attributes with stat: %s" localname)
@@ -3201,9 +3199,8 @@ and `rename'. FILENAME and NEWNAME must be absolute file names."
3201 ok-if-already-exists keep-date preserve-uid-gid)) 3199 ok-if-already-exists keep-date preserve-uid-gid))
3202 3200
3203 ;; Try out-of-band operation. 3201 ;; Try out-of-band operation.
3204 ((and (tramp-method-out-of-band-p v1) 3202 ((tramp-method-out-of-band-p
3205 (> (nth 7 (file-attributes filename)) 3203 v1 (nth 7 (file-attributes filename)))
3206 tramp-copy-size-limit))
3207 (tramp-do-copy-or-rename-file-out-of-band 3204 (tramp-do-copy-or-rename-file-out-of-band
3208 op filename newname keep-date)) 3205 op filename newname keep-date))
3209 3206
@@ -3232,9 +3229,7 @@ and `rename'. FILENAME and NEWNAME must be absolute file names."
3232 3229
3233 ;; If the Tramp file has an out-of-band method, the corresponding 3230 ;; If the Tramp file has an out-of-band method, the corresponding
3234 ;; copy-program can be invoked. 3231 ;; copy-program can be invoked.
3235 ((and (tramp-method-out-of-band-p v) 3232 ((tramp-method-out-of-band-p v (nth 7 (file-attributes filename)))
3236 (> (nth 7 (file-attributes filename))
3237 tramp-copy-size-limit))
3238 (tramp-do-copy-or-rename-file-out-of-band 3233 (tramp-do-copy-or-rename-file-out-of-band
3239 op filename newname keep-date)) 3234 op filename newname keep-date))
3240 3235
@@ -3778,7 +3773,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
3778 (while (< (point) end) 3773 (while (< (point) end)
3779 (let ((start (+ beg (read (current-buffer)))) 3774 (let ((start (+ beg (read (current-buffer))))
3780 (end (+ beg (read (current-buffer))))) 3775 (end (+ beg (read (current-buffer)))))
3781 (if (memq (char-after end) '(?\n ?\s)) 3776 (if (memq (char-after end) '(?\n ?\ ))
3782 ;; End is followed by \n or by " -> ". 3777 ;; End is followed by \n or by " -> ".
3783 (put-text-property start end 'dired-filename t))))) 3778 (put-text-property start end 'dired-filename t)))))
3784 ;; Reove training lines. 3779 ;; Reove training lines.
@@ -4219,9 +4214,8 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
4219 (cond 4214 (cond
4220 ;; `copy-file' handles direct copy and out-of-band methods. 4215 ;; `copy-file' handles direct copy and out-of-band methods.
4221 ((or (tramp-local-host-p v) 4216 ((or (tramp-local-host-p v)
4222 (and (tramp-method-out-of-band-p v) 4217 (tramp-method-out-of-band-p
4223 (> (nth 7 (file-attributes filename)) 4218 v (nth 7 (file-attributes filename))))
4224 tramp-copy-size-limit)))
4225 (copy-file filename tmpfile t t)) 4219 (copy-file filename tmpfile t t))
4226 4220
4227 ;; Use inline encoding for file transfer. 4221 ;; Use inline encoding for file transfer.
@@ -4619,9 +4613,8 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4619 (cond 4613 (cond
4620 ;; `rename-file' handles direct copy and out-of-band methods. 4614 ;; `rename-file' handles direct copy and out-of-band methods.
4621 ((or (tramp-local-host-p v) 4615 ((or (tramp-local-host-p v)
4622 (and (tramp-method-out-of-band-p v) 4616 (tramp-method-out-of-band-p
4623 (> (- (or end (point-max)) (or start (point-min))) 4617 v (- (or end (point-max)) (or start (point-min)))))
4624 tramp-copy-size-limit)))
4625 (condition-case err 4618 (condition-case err
4626 (rename-file tmpfile filename t) 4619 (rename-file tmpfile filename t)
4627 ((error quit) 4620 ((error quit)
@@ -4761,9 +4754,10 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4761;; any other remote command. 4754;; any other remote command.
4762(defun tramp-handle-vc-registered (file) 4755(defun tramp-handle-vc-registered (file)
4763 "Like `vc-registered' for Tramp files." 4756 "Like `vc-registered' for Tramp files."
4764 ;; There could be new files, created by the vc backend. We cannot
4765 ;; reuse the old cache entries, therefore.
4766 (with-parsed-tramp-file-name file nil 4757 (with-parsed-tramp-file-name file nil
4758
4759 ;; There could be new files, created by the vc backend. We cannot
4760 ;; reuse the old cache entries, therefore.
4767 (let (tramp-vc-registered-file-names 4761 (let (tramp-vc-registered-file-names
4768 (tramp-cache-inhibit-cache (current-time)) 4762 (tramp-cache-inhibit-cache (current-time))
4769 (file-name-handler-alist 4763 (file-name-handler-alist
@@ -4774,28 +4768,30 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4774 (tramp-message v 10 "\n%s" tramp-vc-registered-file-names) 4768 (tramp-message v 10 "\n%s" tramp-vc-registered-file-names)
4775 4769
4776 ;; Send just one command, in order to fill the cache. 4770 ;; Send just one command, in order to fill the cache.
4777 (tramp-maybe-send-script 4771 (when tramp-vc-registered-file-names
4778 v 4772 (tramp-maybe-send-script
4779 (format tramp-vc-registered-read-file-names 4773 v
4780 (tramp-get-file-exists-command v) 4774 (format tramp-vc-registered-read-file-names
4781 (format "%s -r" (tramp-get-test-command v))) 4775 (tramp-get-file-exists-command v)
4782 "tramp_vc_registered_read_file_names") 4776 (format "%s -r" (tramp-get-test-command v)))
4783 4777 "tramp_vc_registered_read_file_names")
4784 (dolist 4778
4785 (elt 4779 (dolist
4786 (tramp-send-command-and-read 4780 (elt
4787 v 4781 (tramp-send-command-and-read
4788 (format 4782 v
4789 "tramp_vc_registered_read_file_names %s" 4783 (format
4790 (mapconcat 'tramp-shell-quote-argument 4784 "tramp_vc_registered_read_file_names %s"
4791 tramp-vc-registered-file-names 4785 (mapconcat 'tramp-shell-quote-argument
4792 " ")))) 4786 tramp-vc-registered-file-names
4787 " "))))
4793 4788
4794 (tramp-set-file-property v (car elt) (cadr elt) (cadr (cdr elt))))) 4789 (tramp-set-file-property v (car elt) (cadr elt) (cadr (cdr elt))))))
4795 4790
4796 ;; Second run. Now all requests shall be answered from the file 4791 ;; Second run. Now all `file-exists-p' or `file-readable-p' calls
4797 ;; cache. We unset `process-file-side-effects' in order to keep 4792 ;; shall be answered from the file cache.
4798 ;; the cache when `process-file' calls appear. 4793 ;; We unset `process-file-side-effects' in order to keep the cache
4794 ;; when `process-file' calls appear.
4799 (let (process-file-side-effects) 4795 (let (process-file-side-effects)
4800 (tramp-run-real-handler 'vc-registered (list file))))) 4796 (tramp-run-real-handler 'vc-registered (list file)))))
4801 4797
@@ -7391,9 +7387,15 @@ necessary only. This function will be used in file name completion."
7391 (format "%s@%s:%s" user host localname) 7387 (format "%s@%s:%s" user host localname)
7392 (format "%s:%s" host localname)))) 7388 (format "%s:%s" host localname))))
7393 7389
7394(defun tramp-method-out-of-band-p (vec) 7390(defun tramp-method-out-of-band-p (vec size)
7395 "Return t if this is an out-of-band method, nil otherwise." 7391 "Return t if this is an out-of-band method, nil otherwise."
7396 (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program)) 7392 (and
7393 ;; It shall be an out-of-band method.
7394 (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program)
7395 ;; Either the file size is large enough, or (in rare cases) there
7396 ;; does not exist a remote encoding.
7397 (or (> size tramp-copy-size-limit)
7398 (null (tramp-get-remote-coding vec "remote-encoding")))))
7397 7399
7398(defun tramp-local-host-p (vec) 7400(defun tramp-local-host-p (vec)
7399 "Return t if this points to the local host, nil otherwise." 7401 "Return t if this points to the local host, nil otherwise."
@@ -7522,7 +7524,7 @@ necessary only. This function will be used in file name completion."
7522 (with-connection-property vec "ls-dired" 7524 (with-connection-property vec "ls-dired"
7523 (tramp-message vec 5 "Checking, whether `ls --dired' works") 7525 (tramp-message vec 5 "Checking, whether `ls --dired' works")
7524 (zerop (tramp-send-command-and-check 7526 (zerop (tramp-send-command-and-check
7525 vec (format "%s --diredd /" (tramp-get-ls-command vec))))))) 7527 vec (format "%s --dired /" (tramp-get-ls-command vec)))))))
7526 7528
7527(defun tramp-get-test-command (vec) 7529(defun tramp-get-test-command (vec)
7528 (with-connection-property vec "test" 7530 (with-connection-property vec "test"
@@ -7692,7 +7694,10 @@ If the `tramp-methods' entry does not exist, return NIL."
7692 (around tramp-advice-make-auto-save-file-name () activate) 7694 (around tramp-advice-make-auto-save-file-name () activate)
7693 "Invoke `tramp-handle-make-auto-save-file-name' for Tramp files." 7695 "Invoke `tramp-handle-make-auto-save-file-name' for Tramp files."
7694 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))) 7696 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
7695 (setq ad-return-value (tramp-handle-make-auto-save-file-name)) 7697 ;; We cannot call `tramp-handle-make-auto-save-file-name'
7698 ;; directly, because this would bypass the locking mechanism.
7699 (setq ad-return-value
7700 (tramp-file-name-handler 'make-auto-save-file-name))
7696 ad-do-it)) 7701 ad-do-it))
7697 (add-hook 'tramp-unload-hook 7702 (add-hook 'tramp-unload-hook
7698 (lambda () (ad-unadvise 'make-auto-save-file-name)))) 7703 (lambda () (ad-unadvise 'make-auto-save-file-name))))
@@ -8041,14 +8046,8 @@ Only works for Bourne-like shells."
8041;; SSH instance, would correctly be propagated to the remote process 8046;; SSH instance, would correctly be propagated to the remote process
8042;; automatically; possibly SSH would have to be started with 8047;; automatically; possibly SSH would have to be started with
8043;; "-t". (Markus Triska) 8048;; "-t". (Markus Triska)
8044;; * Set `tramp-copy-size-limit' to 0, when there is no remote
8045;; encoding routine.
8046;; * It makes me wonder if tramp couldn't fall back to ssh when scp 8049;; * It makes me wonder if tramp couldn't fall back to ssh when scp
8047;; isn't on the remote host. (Mark A. Hershberger) 8050;; isn't on the remote host. (Mark A. Hershberger)
8048;; * To improve the behavior in case of things like "git status", it
8049;; might be worthwhile to add some way to indicate that a particular
8050;; use of process-file is (supposed to be) free of side-effects.
8051;; (Stefan Monnier)
8052;; * Use lsh instead of ssh. (Alfred M. Szmidt) 8051;; * Use lsh instead of ssh. (Alfred M. Szmidt)
8053;; * Implement a general server-local-variable mechanism, as there are 8052;; * Implement a general server-local-variable mechanism, as there are
8054;; probably other variables that need different values for different 8053;; probably other variables that need different values for different
@@ -8060,11 +8059,6 @@ Only works for Bourne-like shells."
8060;; rsync). 8059;; rsync).
8061;; * Keep a second connection open for out-of-band methods like scp or 8060;; * Keep a second connection open for out-of-band methods like scp or
8062;; rsync. 8061;; rsync.
8063;; * Partial completion completes word constituents. I find it
8064;; acceptable if method completion works only after :, so that we
8065;; have "/s: TAB" offer completion for the method first, filenames
8066;; afterwards. (David Kastrup)
8067
8068 8062
8069;; Functions for file-name-handler-alist: 8063;; Functions for file-name-handler-alist:
8070;; diff-latest-backup-file -- in diff.el 8064;; diff-latest-backup-file -- in diff.el