changeset 68335:118ceefc8263

Sync with Tramp 2.0.52.
author Michael Albinus <michael.albinus@gmx.de>
date Sun, 22 Jan 2006 21:59:55 +0000
parents def0ffff047f
children f7c8bf774365
files lisp/ChangeLog lisp/net/tramp-ftp.el lisp/net/tramp-util.el lisp/net/tramp-vc.el lisp/net/tramp.el lisp/net/trampver.el man/ChangeLog man/tramp.texi man/trampver.texi
diffstat 9 files changed, 351 insertions(+), 130 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Jan 22 16:24:53 2006 +0000
+++ b/lisp/ChangeLog	Sun Jan 22 21:59:55 2006 +0000
@@ -1,3 +1,45 @@
+2006-01-22  Michael Albinus  <michael.albinus@gmx.de>
+
+	Sync with Tramp 2.0.52.
+
+	* net/tramp.el, net/tramp-ftp.el, net/tramp-util.el,
+	net/tramp-vc.el: Add code for unloading Tramp.  See comment before
+	`tramp-unload-tramp' for checklist.
+
+	* net/tramp.el: Require `timer-funcs' instead of `timer' if in
+	XEmacs.  Contributed by Steve Youngs <steve@sxemacs.org>.
+	(tramp-unload-file-name-handler-alist)
+	(tramp-unload-tramp): New defuns.
+	(tramp-advice-PC-expand-many-files): New defadvice.
+	(tramp-save-PC-expand-many-files, tramp-setup-complete) Defuns
+	removed.
+	(tramp-handle-expand-file-name): Remove double slash.
+	(tramp-handle-file-attributes-with-ls): Return t as 9th attribute.
+	It doesn't matter, because it will be converted later on.
+	(tramp-handle-file-ownership-preserved-p): Rewritten.  The old
+	implementation was just heuristic.
+	(tramp-post-connection): Set uid and gid properties.
+	(tramp-convert-file-attributes): Set file's gid change bit.
+	(tramp-get-remote-uid, tramp-get-remote-gid): New defuns.
+	(tramp-handle-expand-file-name): Use "~root" for tilde expansion
+	in case of su(do)? methods.  The home directory of the local user
+	will be taken else.
+	(tramp-open-connection-telnet)
+	(tramp-open-connection-rsh, tramp-open-connection-su)
+	(tramp-open-connection-multi): Set PS1 to "$ ".  Otherwise, a
+	local shell prompt could hurt.  Reported by Romain Francoise
+	<romain@orebokech.com>.
+	(tramp-let-maybe): Add `edebug-form-spec' property.
+	(tramp-handle-expand-file-name): Bind `default-directory' locally
+	to "/" in order to avoid problems with UNC shares or Cygwin
+	mounts.
+	(tramp-md5-function): Fix typo in error message.
+
+	* net/tramp-ftp.el (tramp-ftp-enable-ange-ftp): New defun.
+
+	* net/tramp-util.el (top): Apply `ignore' instead of `identity'
+	for byte-compiler pacification.
+
 2006-01-22  Andre Spiegel  <spiegel@gnu.org>
 
 	* vc-rcs.el (vc-rcs-state-heuristic): Use file-attributes with
--- a/lisp/net/tramp-ftp.el	Sun Jan 22 16:24:53 2006 +0000
+++ b/lisp/net/tramp-ftp.el	Sun Jan 22 21:59:55 2006 +0000
@@ -1,6 +1,6 @@
 ;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP -*- coding: iso-8859-1; -*-
 
-;; Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
@@ -63,8 +63,40 @@
 	(a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)))
     (setq file-name-handler-alist
 	  (delete a1 (delete a2 file-name-handler-alist)))))
-(tramp-disable-ange-ftp)
-(eval-after-load "ange-ftp" '(tramp-disable-ange-ftp))
+
+(eval-after-load "ange-ftp"
+  '(when (functionp 'tramp-disable-ange-ftp)
+     (tramp-disable-ange-ftp)))
+
+;;;###autoload
+(defun tramp-ftp-enable-ange-ftp ()
+  ;; The following code is commented out in Ange-FTP.
+
+  ;;; This regexp takes care of real ange-ftp file names (with a slash
+  ;;; and colon).
+  ;;; Don't allow the host name to end in a period--some systems use /.:
+  (or (assoc "^/[^/:]*[^/:.]:" file-name-handler-alist)
+      (setq file-name-handler-alist
+	    (cons '("^/[^/:]*[^/:.]:" . ange-ftp-hook-function)
+		  file-name-handler-alist)))
+
+  ;;; This regexp recognizes absolute filenames with only one component,
+  ;;; for the sake of hostname completion.
+  (or (assoc "^/[^/:]*\\'" file-name-handler-alist)
+      (setq file-name-handler-alist
+	    (cons '("^/[^/:]*\\'" . ange-ftp-completion-hook-function)
+		  file-name-handler-alist)))
+
+  ;;; This regexp recognizes absolute filenames with only one component
+  ;;; on Windows, for the sake of hostname completion.
+  (and (memq system-type '(ms-dos windows-nt))
+       (or (assoc "^[a-zA-Z]:/[^/:]*\\'" file-name-handler-alist)
+	   (setq file-name-handler-alist
+		 (cons '("^[a-zA-Z]:/[^/:]*\\'" .
+			 ange-ftp-completion-hook-function)
+		       file-name-handler-alist)))))
+
+(add-hook 'tramp-ftp-unload-hook 'tramp-ftp-enable-ange-ftp)
 
 ;; Define FTP method ...
 (defcustom tramp-ftp-method "ftp"
--- a/lisp/net/tramp-util.el	Sun Jan 22 16:24:53 2006 +0000
+++ b/lisp/net/tramp-util.el	Sun Jan 22 21:59:55 2006 +0000
@@ -1,7 +1,8 @@
 ;;; -*- coding: iso-2022-7bit; -*-
 ;;; tramp-util.el --- Misc utility functions to use with Tramp
 
-;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
+;;   2006 Free Software Foundation, Inc.
 
 ;; Author: kai.grossjohann@gmx.net
 ;; Keywords: comm, extensions, processes
@@ -31,6 +32,10 @@
 (eval-when-compile (require 'cl))
 (require 'compile)
 (require 'tramp)
+(add-hook 'tramp-util-unload-hook
+	  '(lambda ()
+	     (when (featurep 'tramp)
+	       (unload-feature 'tramp 'force))))
 
 ;; Define a Tramp minor mode. It's intention is to redefine some keys for Tramp
 ;; specific functions, like compilation.
@@ -42,7 +47,7 @@
       (defalias 'define-minor-mode 'identity)
       (defvar tramp-minor-mode))
   (unless (featurep 'xemacs)
-      (defalias 'add-menu-button 'identity)))
+    (defalias 'add-menu-button 'ignore)))
 
 (defvar tramp-minor-mode-map (make-sparse-keymap)
   "Keymap for Tramp minor mode.")
@@ -57,7 +62,14 @@
 	(and tramp-minor-mode (tramp-tramp-file-p default-directory))))
 
 (add-hook 'find-file-hooks 'tramp-minor-mode t)
+(add-hook 'tramp-util-unload-hook
+	  '(lambda ()
+	     (remove-hook 'find-file-hooks 'tramp-minor-mode)))
+
 (add-hook 'dired-mode-hook 'tramp-minor-mode t)
+(add-hook 'tramp-util-unload-hook
+	  '(lambda ()
+	     (remove-hook 'dired-mode-hook 'tramp-minor-mode)))
 
 (defun tramp-remap-command (old-command new-command)
   "Replaces bindings of OLD-COMMAND by NEW-COMMAND.
--- a/lisp/net/tramp-vc.el	Sun Jan 22 16:24:53 2006 +0000
+++ b/lisp/net/tramp-vc.el	Sun Jan 22 21:59:55 2006 +0000
@@ -1,7 +1,7 @@
 ;;; tramp-vc.el --- Version control integration for TRAMP.el
 
 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Daniel Pittman <daniel@danann.net>
 ;; Keywords: comm, processes
@@ -220,34 +220,37 @@
 ;; Daniel Pittman <daniel@danann.net>
 ;;-(if (fboundp 'vc-call-backend)
 ;;-    () ;; This is the new VC for which we don't have an appropriate advice yet
+;;-)
 (unless (fboundp 'process-file)
-(if (fboundp 'vc-call-backend)
+  (if (fboundp 'vc-call-backend)
+      (defadvice vc-do-command
+	(around tramp-advice-vc-do-command
+		(buffer okstatus command file &rest flags)
+		activate)
+	"Invoke tramp-vc-do-command for tramp files."
+	(let ((file (symbol-value 'file)))    ;pacify byte-compiler
+	  (if (or (and (stringp file)     (tramp-tramp-file-p file))
+		  (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
+	      (setq ad-return-value
+		    (apply 'tramp-vc-do-command-new buffer okstatus command
+			   file ;(or file (buffer-file-name))
+			   flags))
+	    ad-do-it)))
     (defadvice vc-do-command
       (around tramp-advice-vc-do-command
-              (buffer okstatus command file &rest flags)
-              activate)
+	      (buffer okstatus command file last &rest flags)
+	      activate)
       "Invoke tramp-vc-do-command for tramp files."
-      (let ((file (symbol-value 'file)))    ;pacify byte-compiler
-        (if (or (and (stringp file)     (tramp-tramp-file-p file))
-                (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
-            (setq ad-return-value
-                  (apply 'tramp-vc-do-command-new buffer okstatus command
-                         file ;(or file (buffer-file-name))
-                         flags))
-          ad-do-it)))
-  (defadvice vc-do-command
-    (around tramp-advice-vc-do-command
-            (buffer okstatus command file last &rest flags)
-            activate)
-    "Invoke tramp-vc-do-command for tramp files."
-    (let ((file (symbol-value 'file)))  ;pacify byte-compiler
-      (if (or (and (stringp file)     (tramp-tramp-file-p file))
-              (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
-          (setq ad-return-value
-                (apply 'tramp-vc-do-command buffer okstatus command
-                       (or file (buffer-file-name)) last flags))
-        ad-do-it)))))
-;;-)
+      (let ((file (symbol-value 'file)))  ;pacify byte-compiler
+	(if (or (and (stringp file)     (tramp-tramp-file-p file))
+		(and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
+	    (setq ad-return-value
+		  (apply 'tramp-vc-do-command buffer okstatus command
+			 (or file (buffer-file-name)) last flags))
+	  ad-do-it))))
+
+  (add-hook 'tramp-unload-hook
+	    '(lambda () (ad-unadvise 'vc-do-command))))
 
 
 ;; XEmacs uses this to do some of its work. Like vc-do-command, we
@@ -324,6 +327,9 @@
                      (or file (buffer-file-name)) args))
       ad-do-it)))
 
+(add-hook 'tramp-unload-hook
+	  '(lambda () (ad-unadvise 'vc-simple-command)))
+
 
 ;; `vc-workfile-unchanged-p'
 ;; This function does not deal well with remote files, so we do the
@@ -364,6 +370,9 @@
             (tramp-vc-workfile-unchanged-p filename want-differences-if-changed))
     ad-do-it))
 
+(add-hook 'tramp-unload-hook
+	  '(lambda () (ad-unadvise 'vc-workfile-unchanged-p)))
+
 
 ;; Redefine a function from vc.el -- allow tramp files.
 ;; `save-match-data' seems not to be required -- it isn't in
@@ -445,6 +454,9 @@
 		     (tramp-handle-vc-user-login-name uid)))) ; get the owner name
         ad-do-it)))                     ; else call the original
 
+(add-hook 'tramp-unload-hook
+	  '(lambda () (ad-unadvise 'vc-user-login-name)))
+
 
 ;; Determine the name of the user owning a file.
 (defun tramp-file-owner (filename)
@@ -486,6 +498,9 @@
 		     (tramp-file-owner filename)))) ; get the owner name
         ad-do-it)))                     ; else call the original
 
+(add-hook 'tramp-unload-hook
+	  '(lambda () (ad-unadvise 'vc-file-owner)))
+
 
 ;; We need to make the version control software backend version
 ;; information local to the current buffer. This is because each TRAMP
@@ -506,7 +521,11 @@
              (tramp-tramp-file-p (buffer-file-name)))
     (make-local-variable 'vc-rcs-release)
     (setq vc-rcs-release nil)))
+
 (add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t)
+(add-hook 'tramp-unload-hook
+	  '(lambda ()
+	     (remove-hook 'find-file-hooks 'tramp-vc-setup-for-remote)))
 
 ;; No need to load this again if anyone asks.
 (provide 'tramp-vc)
--- a/lisp/net/tramp.el	Sun Jan 22 16:24:53 2006 +0000
+++ b/lisp/net/tramp.el	Sun Jan 22 21:59:55 2006 +0000
@@ -2,7 +2,7 @@
 ;;; tramp.el --- Transparent Remote Access, Multiple Protocol
 
 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;   2005 Free Software Foundation, Inc.
+;;   2005, 2006 Free Software Foundation, Inc.
 
 ;; Author: Kai Gro,A_(Bjohann <kai.grossjohann@gmx.net>
 ;;         Michael Albinus <michael.albinus@gmx.de>
@@ -67,8 +67,15 @@
 
 ;; The Tramp version number and bug report address, as prepared by configure.
 (require 'trampver)
-
-(require 'timer)
+(add-hook 'tramp-unload-hook
+	  '(lambda ()
+	     (when (featurep 'trampver)
+	       (unload-feature 'trampver 'force))))
+
+(if (featurep 'xemacs)
+    (require 'timer-funcs)
+  (require 'timer))
+
 (require 'format-spec)                  ;from Gnus 5.8, also in tar ball
 ;; As long as password.el is not part of (X)Emacs, it shouldn't
 ;; be mandatory
@@ -87,6 +94,10 @@
 
 (autoload 'tramp-uuencode-region "tramp-uu"
   "Implementation of `uuencode' in Lisp.")
+(add-hook 'tramp-unload-hook
+	  '(lambda ()
+	     (when (featurep 'tramp-uu)
+	       (unload-feature 'tramp-uu 'force))))
 
 (unless (fboundp 'uudecode-decode-region)
   (autoload 'uudecode-decode-region "uudecode"))
@@ -110,10 +121,20 @@
 ;; tramp-ftp supports Ange-FTP only.  Not suited for XEmacs therefore.
 (unless (featurep 'xemacs)
   (eval-after-load "tramp"
-    '(require 'tramp-ftp)))
+    '(progn
+       (require 'tramp-ftp)
+       (add-hook 'tramp-unload-hook
+		 '(lambda ()
+		    (when (featurep 'tramp-ftp)
+		      (unload-feature 'tramp-ftp 'force)))))))
 (when (and tramp-unified-filenames (featurep 'xemacs))
   (eval-after-load "tramp"
-    '(require 'tramp-efs)))
+    '(progn
+       (require 'tramp-efs)
+       (add-hook 'tramp-unload-hook
+		 '(lambda ()
+		    (when (featurep 'tramp-efs)
+		      (unload-feature 'tramp-efs 'force)))))))
 
 ;; tramp-smb uses "smbclient" from Samba.
 ;; Not available under Cygwin and Windows, because they don't offer
@@ -121,7 +142,12 @@
 ;; UNC file names like "//host/share/localname".
 (unless (memq system-type '(cygwin windows-nt))
   (eval-after-load "tramp"
-    '(require 'tramp-smb)))
+    '(progn
+       (require 'tramp-smb)
+       (add-hook 'tramp-unload-hook
+		 '(lambda ()
+		    (when (featurep 'tramp-smb)
+		      (unload-feature 'tramp-smb 'force)))))))
 
 (eval-when-compile
   (require 'cl)
@@ -1445,7 +1471,7 @@
 	((fboundp 'md5-encode)
 	 (lambda (x) (base64-encode-string
 		      (funcall (symbol-function 'md5-encode) x))))
-	(t (error "Coulnd't find an `md5' function")))
+	(t (error "Couldn't find an `md5' function")))
   "Function to call for running the MD5 algorithm.")
 
 (defvar tramp-end-of-output
@@ -2012,6 +2038,7 @@
      (let ((,variable ,value))
        ,@body)))
 (put 'tramp-let-maybe 'lisp-indent-function 2)
+(put 'tramp-let-maybe 'edebug-form-spec t)
 
 ;;; Config Manipulation Functions:
 
@@ -2370,8 +2397,8 @@
      ;; 8. File modes, as a string of ten letters or dashes as in ls -l.
      res-filemodes
      ;; 9. t iff file's gid would change if file were deleted and
-     ;; recreated.
-     nil				;hm?
+     ;; recreated.  Will be set in `tramp-convert-file-attributes'
+     t
      ;; 10. inode number.
      res-inode
      ;; 11. Device number.  Will be replaced by a virtual device number.
@@ -2627,9 +2654,12 @@
 (defun tramp-handle-file-ownership-preserved-p (filename)
   "Like `file-ownership-preserved-p' for tramp files."
   (with-parsed-tramp-file-name filename nil
-    (or (not (file-exists-p filename))
-	;; Existing files must be writable.
-	(zerop (tramp-run-test "-O" filename)))))
+    (let ((attributes (file-attributes filename)))
+      ;; Return t if the file doesn't exist, since it's true that no
+      ;; information would be lost by an (attempted) delete and create.
+      (or (null attributes)
+	  (= (nth 2 attributes)
+	     (tramp-get-remote-uid multi-method method user host))))))
 
 ;; Other file name ops.
 
@@ -3487,6 +3517,17 @@
 	(when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
 	  (let ((uname (match-string 1 localname))
 		(fname (match-string 2 localname)))
+	    ;; We cannot simply apply "~/", because under sudo "~/" is
+	    ;; expanded to the local user home directory but to the
+	    ;; root home directory.  On the other hand, using always
+	    ;; the default user name for tilde expansion is not
+	    ;; appropriate either, because ssh and companions might
+	    ;; use a user name from the config file.
+	    (when (and (string-equal uname "~")
+		       (string-match
+			"\\`su\\(do\\)?\\'"
+			(tramp-find-method multi-method method user host)))
+	      (setq uname (concat uname (or user "root"))))
 	    ;; CCC fanatic error checking?
 	    (set-buffer (tramp-get-buffer multi-method method user host))
 	    (erase-buffer)
@@ -3499,17 +3540,24 @@
 	    (setq uname (buffer-substring (point) (tramp-line-end-position)))
 	    (setq localname (concat uname fname))
 	    (erase-buffer)))
+	;; There might be a double slash, for example when "~/"
+	;; expands to "/". Remove this.
+	(while (string-match "//" localname)
+	  (setq localname (replace-match "/" t t localname)))
 	;; No tilde characters in file name, do normal
 	;; expand-file-name (this does "/./" and "/../").  We bind
-	;; directory-sep-char here for XEmacs on Windows, which
-	;; would otherwise use backslash.
+	;; directory-sep-char here for XEmacs on Windows, which would
+	;; otherwise use backslash.  `default-directory' is bound to
+	;; "/", because on Windows there would be problems with UNC
+	;; shares or Cygwin mounts.
 	(tramp-let-maybe directory-sep-char ?/
-	  (tramp-make-tramp-file-name
-	   multi-method (or method (tramp-find-default-method user host))
-	   user host
-	   (tramp-drop-volume-letter
-	    (tramp-run-real-handler 'expand-file-name
-				    (list localname)))))))))
+	  (let ((default-directory "/"))
+	    (tramp-make-tramp-file-name
+	     multi-method (or method (tramp-find-default-method user host))
+	     user host
+	     (tramp-drop-volume-letter
+	      (tramp-run-real-handler 'expand-file-name
+				      (list localname))))))))))
 
 ;; old version follows.  it uses ".." to cross file handler
 ;; boundaries.
@@ -4294,6 +4342,17 @@
 	     (cons tramp-completion-file-name-regexp
 		   'tramp-completion-file-name-handler))
 
+;;;###autoload
+(defun tramp-unload-file-name-handler-alist ()
+  (setq file-name-handler-alist
+	(delete (rassoc 'tramp-file-name-handler
+			file-name-handler-alist)
+		(delete (rassoc 'tramp-completion-file-name-handler
+				file-name-handler-alist)
+			file-name-handler-alist))))
+
+(add-hook 'tramp-unload-hook 'tramp-unload-file-name-handler-alist)
+
 (defun tramp-repair-jka-compr ()
   "If jka-compr is already loaded, move it to the front of
 `file-name-handler-alist'.  On Emacs 22 or so this will not be
@@ -4353,22 +4412,16 @@
 		 (read (current-buffer))))))
 	(list (expand-file-name name))))))
 
-;; Check for complete.el and override PC-expand-many-files if appropriate.
-(eval-and-compile
-  (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning
-
-(defun tramp-setup-complete ()
-  (fset 'tramp-save-PC-expand-many-files
-        (symbol-function 'PC-expand-many-files))
-  (defun PC-expand-many-files (name)
-    (if (tramp-tramp-file-p name)
-        (funcall (symbol-function 'expand-many-files) name)
-      (tramp-save-PC-expand-many-files name))))
-
-;; Why isn't eval-after-load sufficient?
-(if (fboundp 'PC-expand-many-files)
-    (tramp-setup-complete)
-  (eval-after-load "complete" '(tramp-setup-complete)))
+(eval-after-load "complete"
+  '(progn
+     (defadvice PC-expand-many-files
+       (around tramp-advice-PC-expand-many-files (name) activate)
+       "Invoke `tramp-handle-expand-many-files' for tramp files."
+       (if (tramp-tramp-file-p name)
+	   (setq ad-return-value (tramp-handle-expand-many-files name))
+	 ad-do-it))
+     (add-hook 'tramp-unload-hook
+	       '(lambda () (ad-unadvise 'PC-expand-many-files)))))
 
 ;;; File name handler functions for completion mode
 
@@ -4940,6 +4993,9 @@
              auto-save-default)
     (auto-save-mode 1)))
 (add-hook 'find-file-hooks 'tramp-set-auto-save t)
+(add-hook 'tramp-unload-hook
+	  '(lambda ()
+	     (remove-hook 'find-file-hooks 'tramp-set-auto-save)))
 
 (defun tramp-run-test (switch filename)
   "Run `test' on the remote system, given a SWITCH and a FILENAME.
@@ -5532,6 +5588,7 @@
 		   (or user (user-login-name)) host method)
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
+      (setenv "PS1" "$ ")
       (let* ((default-directory (tramp-temporary-file-directory))
 	     ;; If we omit the conditional here, then we would use
 	     ;; `undecided-dos' in some cases.  With the conditional,
@@ -5608,6 +5665,7 @@
 	(setq login-args (cons "-p" (cons (match-string 2 host) login-args)))
 	(setq real-host (match-string 1 host)))
       (setenv "TERM" tramp-terminal-type)
+      (setenv "PS1" "$ ")
       (let* ((default-directory (tramp-temporary-file-directory))
 	     ;; If we omit the conditional, we would use
 	     ;; `undecided-dos' in some cases.  With the conditional,
@@ -5659,6 +5717,7 @@
 		   (or user "<root>") method)
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
+      (setenv "PS1" "$ ")
       (let* ((default-directory (tramp-temporary-file-directory))
 	     ;; If we omit the conditional, we use `undecided-dos' in
 	     ;; some cases.  With the conditional, we use nil in these
@@ -5723,6 +5782,7 @@
     (tramp-message 7 "Opening `%s' connection..." multi-method)
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
+      (setenv "PS1" "$ ")
       (let* ((default-directory (tramp-temporary-file-directory))
 	     ;; If we omit the conditional, we use `undecided-dos' in
 	     ;; some cases.  With the conditional, we use nil in these
@@ -6203,8 +6263,17 @@
 				   "ln" tramp-remote-path nil)))
     (when ln
       (tramp-set-connection-property "ln" ln multi-method method user host)))
+  ;; Set uid and gid.
   (erase-buffer)
+  (tramp-send-command multi-method method user host "id -u; id -g")
+  (tramp-wait-for-output)
+  (goto-char (point-min))
+  (tramp-set-connection-property
+   "uid" (read (current-buffer)) multi-method method user host)
+  (tramp-set-connection-property
+   "gid" (read (current-buffer)) multi-method method user host)
   ;; Find the right encoding/decoding commands to use.
+  (erase-buffer)
   (unless (tramp-method-out-of-band-p multi-method method user host)
     (tramp-find-inline-encoding multi-method method user host))
   ;; If encoding/decoding command are given, test to see if they work.
@@ -6700,6 +6769,10 @@
   (unless (stringp (nth 8 attr))
     ;; Convert file mode bits to string.
     (setcar (nthcdr 8 attr) (tramp-file-mode-from-int (nth 8 attr))))
+  ;; Set file's gid change bit.
+  (setcar (nthcdr 9 attr)
+	  (not (= (nth 3 attr)
+		  (tramp-get-remote-gid multi-method method user host))))
   ;; Set virtual device number.
   (setcar (nthcdr 11 attr)
           (tramp-get-device multi-method method user host))
@@ -6957,6 +7030,12 @@
 (defun tramp-get-remote-ln (multi-method method user host)
   (tramp-get-connection-property "ln" nil multi-method method user host))
 
+(defun tramp-get-remote-uid (multi-method method user host)
+  (tramp-get-connection-property "uid" nil multi-method method user host))
+
+(defun tramp-get-remote-gid (multi-method method user host)
+  (tramp-get-connection-property "gid" nil multi-method method user host))
+
 ;; Get a property of a TRAMP connection.
 (defun tramp-get-connection-property
   (property default multi-method method user host)
@@ -6967,7 +7046,7 @@
     (let (error)
       (condition-case nil
 	  (symbol-value (intern (concat "tramp-connection-property-" property)))
-	(error	default)))))
+	(error default)))))
 
 ;; Set a property of a TRAMP connection.
 (defun tramp-set-connection-property
@@ -7045,7 +7124,9 @@
     "Invoke `tramp-handle-make-auto-save-file-name' for tramp files."
     (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))
 	(setq ad-return-value (tramp-handle-make-auto-save-file-name))
-      ad-do-it)))
+      ad-do-it))
+  (add-hook 'tramp-unload-hook
+	    '(lambda () (ad-unadvise 'make-auto-save-file-name))))
 
 ;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have
 ;; permission 0666 minus umask. This is a security threat.
@@ -7069,7 +7150,10 @@
 	    (and (featurep 'xemacs)
 		 (= emacs-major-version 21)
 		 (> emacs-minor-version 4)))
-  (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes))
+  (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)
+  (add-hook 'tramp-unload-hook
+	    '(lambda ()
+	       (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes))))
 
 (defun tramp-subst-strs-in-string (alist string)
   "Replace all occurrences of the string FROM with TO in STRING.
@@ -7296,7 +7380,9 @@
 	      (setq ad-return-value (list name))))
 	;; If it is not a Tramp file, just run the original function.
 	(let ((res ad-do-it))
-	  (setq ad-return-value (or res (list name))))))))
+	  (setq ad-return-value (or res (list name)))))))
+  (add-hook 'tramp-unload-hook
+	    '(lambda () (ad-unadvise 'file-expand-wildcards))))
 
 ;; Tramp version is useful in a number of situations.
 
@@ -7521,6 +7607,25 @@
 
 (defalias 'tramp-submit-bug 'tramp-bug)
 
+;; Checklist for `tramp-unload-hook'
+;; - Unload all `tramp-*' packages
+;; - Reset `file-name-handler-alist'
+;; - Cleanup hooks where Tramp functions are in
+;; - Cleanup advised functions
+;; - Cleanup autoloads
+;;;###autoload
+(defun tramp-unload-tramp ()
+  (interactive)
+  ;; When Tramp is not loaded yet, its autoloads are still active.
+  (tramp-unload-file-name-handler-alist)
+  ;; ange-ftp settings must be enabled.
+  (when (functionp 'tramp-ftp-enable-ange-ftp)
+    (funcall (symbol-function 'tramp-ftp-enable-ange-ftp)))
+  ;; `tramp-util' unloads also `tramp'.
+  (condition-case nil ;; maybe its not loaded yet.
+      (unload-feature (if (featurep 'tramp-util) 'tramp-util 'tramp) 'force)
+    (error nil)))
+
 (provide 'tramp)
 
 ;; Make sure that we get integration with the VC package.
@@ -7528,7 +7633,12 @@
 ;; This must come after (provide 'tramp) because tramp-vc.el
 ;; requires tramp.
 (eval-after-load "vc"
-  '(require 'tramp-vc))
+  '(progn
+     (require 'tramp-vc)
+     (add-hook 'tramp-unload-hook
+	       '(lambda ()
+		  (when (featurep 'tramp-vc)
+		    (unload-feature 'tramp-vc 'force))))))
 
 ;;; TODO:
 
--- a/lisp/net/trampver.el	Sun Jan 22 16:24:53 2006 +0000
+++ b/lisp/net/trampver.el	Sun Jan 22 21:59:55 2006 +0000
@@ -30,7 +30,7 @@
 ;; are auto-frobbed from configure.ac, so you should edit that file and run
 ;; "autoconf && ./configure" to change them.
 
-(defconst tramp-version "2.0.51"
+(defconst tramp-version "2.0.52"
   "This version of Tramp.")
 
 (defconst tramp-bug-report-address "tramp-devel@gnu.org"
--- a/man/ChangeLog	Sun Jan 22 16:24:53 2006 +0000
+++ b/man/ChangeLog	Sun Jan 22 21:59:55 2006 +0000
@@ -1,3 +1,13 @@
+2006-01-22  Michael Albinus  <michael.albinus@gmx.de>
+
+	Sync with Tramp 2.0.52.
+
+	* tramp.texi (Frequently Asked Questions): Remove Ange-FTP item.
+	Add Tramp disabling item.  New item for common connection
+	problems.
+	(various): Apply "ftp" as method for the download URL.
+	(Bug Reports): Refer to FAQ for common problems.
+
 2006-01-21  Eli Zaretskii  <eliz@gnu.org>
 
 	* widget.texi (User Interface): Use @key for TAB.
--- a/man/tramp.texi	Sun Jan 22 16:24:53 2006 +0000
+++ b/man/tramp.texi	Sun Jan 22 21:59:55 2006 +0000
@@ -25,8 +25,8 @@
 @end macro
 
 @copying
-Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004,
-   2005 Free Software Foundation, Inc.
+Copyright @copyright{} 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -111,7 +111,7 @@
 @end ifset
 
 The latest release of @value{tramp} is available for
-@uref{http://ftp.gnu.org/gnu/tramp/, download}, or you may see
+@uref{ftp://ftp.gnu.org/gnu/tramp/, download}, or you may see
 @ref{Obtaining Tramp} for more details, including the CVS server
 details.
 
@@ -378,7 +378,7 @@
 
 @value{tramp} is freely available on the Internet and the latest
 release may be downloaded from
-@uref{http://ftp.gnu.org/gnu/tramp/}. This release includes the full
+@uref{ftp://ftp.gnu.org/gnu/tramp/}. This release includes the full
 documentation and code for @value{tramp}, suitable for installation.
 But GNU Emacs (22 or later) includes @value{tramp} already, and there
 is a @value{tramp} package for XEmacs, as well.  So maybe it is easier
@@ -1946,7 +1946,9 @@
 
 When submitting a bug report, please try to describe in excruciating
 detail the steps required to reproduce the problem, the setup of the
-remote machine and any special conditions that exist.
+remote machine and any special conditions that exist.  You should also
+check that your problem is not described already in @xref{Frequently
+Asked Questions}.
 
 If you can identify a minimal test case that reproduces the problem,
 include that with your bug report. This will make it much easier for the
@@ -1964,7 +1966,7 @@
 @value{tramp} is available under the URL below.
 
 @noindent
-@uref{http://ftp.gnu.org/gnu/tramp/}
+@uref{ftp://ftp.gnu.org/gnu/tramp/}
 
 @noindent
 There is also a Savannah project page.
@@ -1972,6 +1974,7 @@
 @noindent
 @uref{http://savannah.gnu.org/projects/tramp/}
 
+
 @item
 Which systems does it work on?
 
@@ -2003,49 +2006,32 @@
 
 
 @item
-I can't stop @value{ftppackagename} starting with @value{emacsname}
-
-@ifset emacs
-@value{ftppackagename} is loaded from @value{tramp} automatically if you
-require a file by the ftp method.  Unfortunately, there are some Lisp
-packages which make @value{ftppackagename} file name handlers active.
-You can see it applying @kbd{C-h v file-name-handler-alist}:
-
-@example
-file-name-handler-alist's value is
-(("^/[^/:]*\\'" . ange-ftp-completion-hook-function)
- ("^/[^/:]*[^/:.]:" . ange-ftp-hook-function)
- ("^/[^/]*$" . tramp-completion-file-name-handler)
- ("\\`/[^/:]+:" . tramp-file-name-handler)
- ("\\`/:" . file-name-non-special))
-@end example
-
-Please try to find out which package is responsible for loading
-@value{ftppackagename}, and raise a bug report.
-
-A workaround is to require @value{ftppackagename} before @value{tramp} in
-your @file{~/.emacs}, because @value{tramp} cleans up the entries in
-@code{file-name-handler-alist}:
-
-@lisp
-;; @value{ftppackagename} temporarily required
-(require 'ange-ftp)
-;; @value{tramp} cleans up @code{file-name-handler-alist}
-(require 'tramp)
-@end lisp
-@end ifset
-
-@ifset xemacs
-Not all the older versions of @value{tramp} supported @value{emacsname}
-correctly.  The first thing to do is to make sure that you have the
-latest version of @value{tramp} installed.
-
-If you do, please try and find out exactly the conditions required for
-the @value{ftppackagename} handlers to fire.  If you can, putting a
-breakpoint on @code{efs-ftp-path} and sending in the stack trace along
-with your bug report would make it easier for the developers to work out
-what is going wrong.
-@end ifset
+@value{tramp} does not connect to the remote host
+
+When @value{tramp} does not connect to the remote host, there are two
+reasons heading the bug mailing list:
+
+@itemize @minus
+
+@item
+Unknown characters in the prompt
+
+@value{tramp} needs to recognize the prompt on the remote machine
+after execution any command.  This is not possible, when the prompt
+contains unknown characters like escape sequences for coloring.  This
+should be avoided on the remote side.  @xref{Remote shell setup}. for
+setting the regular expression detecting the prompt.
+
+@item
+@value{tramp} doesn't transfer strings with more than 500 characters
+correctly
+
+On some few systems, the implementation of @code{process-send-string}
+seems to be broken for longer strings.  This case, you should
+customize the variable @code{tramp-chunksize} to 500.  For a
+description how to determine whether this is necessary see the
+documentation of @code{tramp-chunksize}.
+@end itemize
 
 
 @item
@@ -2132,14 +2118,24 @@
 
 
 @item
-@value{tramp} doesn't transfer strings with more than 500 characters
-correctly
-
-On some few systems, the implementation of @code{process-send-string}
-seems to be broken for longer strings.  This case, you should
-customize the variable @code{tramp-chunksize} to 500.  For a
-description how to determine whether this is necessary see the
-documentation of @code{tramp-chunksize}.
+How can I disable @value{tramp}?
+
+Shame on you, why did you read until now?
+
+@ifset emacs
+If you just want to have @value{ftppackagename} as default remote
+files access package, you should apply the following code:
+
+@lisp
+(setq tramp-default-method "ftp")
+@end lisp
+@end ifset
+
+Unloading @value{tramp} can be achieved by applying @kbd{M-x
+tramp-unload-tramp}.
+@ifset emacs
+This resets also the @value{ftppackagename} plugins.
+@end ifset
 @end itemize
 
 
--- a/man/trampver.texi	Sun Jan 22 16:24:53 2006 +0000
+++ b/man/trampver.texi	Sun Jan 22 21:59:55 2006 +0000
@@ -4,7 +4,7 @@
 @c In the Tramp CVS, the version number is auto-frobbed from
 @c configure.ac, so you should edit that file and run
 @c "autoconf && ./configure" to change the version number.
-@set trampver 2.0.51
+@set trampver 2.0.52
 
 @c Other flags from configuration
 @set prefix /usr/local