unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Hansen <lists@soem.dk>
Subject: Bugfix and improved error handling
Date: Tue, 21 Nov 2006 20:22:03 +0100	[thread overview]
Message-ID: <456351DB.8010805@soem.dk> (raw)

[-- Attachment #1: Type: text/plain, Size: 387 bytes --]

The attached patch has improved error handling for out-of-band copying
and some bug fixes.
The changes are:

1. Give error message "permission denied"/"not a regular file"/"no such
file or directory" rather than the misleading "login failed" when
appropriate.
2. Also kill the copy program buffer when an error occurs (bugfix).
3. Use pscp as default method under windows.

Objections?


[-- Attachment #2: tramp.diff --]
[-- Type: text/x-patch, Size: 7045 bytes --]

*** /home/lh/cvsroot/emacs/lisp/net/tramp.el	2006-11-18 19:48:32.000000000 +0100
--- tramp.el	2006-11-21 20:05:28.000000000 +0100
***************
*** 673,680 ****
  
  (defcustom tramp-default-method
    (if (and (fboundp 'executable-find)
! 	   (executable-find "plink"))
!       "plink"
      "scp")
    "*Default method to use for transferring files.
  See `tramp-methods' for possibilities.
--- 673,680 ----
  
  (defcustom tramp-default-method
    (if (and (fboundp 'executable-find)
! 	   (executable-find "pscp"))
!       "pscp"
      "scp")
    "*Default method to use for transferring files.
  See `tramp-methods' for possibilities.
***************
*** 1327,1351 ****
  Whenever a pattern matches, the corresponding action is performed.
  Each item looks like (PATTERN ACTION).
  
! The PATTERN should be a symbol, a variable.  The value of this
! variable gives the regular expression to search for.  Note that the
! regexp must match at the end of the buffer, \"\\'\" is implicitly
! appended to it.
  
! The ACTION should also be a symbol, but a function.  When the
! corresponding PATTERN matches, the ACTION function is called."
    :group 'tramp
!   :type '(repeat (list variable function)))
  
  (defcustom tramp-actions-copy-out-of-band
    '((tramp-password-prompt-regexp tramp-action-password)
      (tramp-wrong-passwd-regexp tramp-action-permission-denied)
      (tramp-process-alive-regexp tramp-action-out-of-band))
    "List of pattern/action pairs.
  This list is used for copying/renaming with out-of-band methods.
  See `tramp-actions-before-shell' for more info."
    :group 'tramp
!   :type '(repeat (list variable function)))
  
  (defcustom tramp-multi-actions
    '((tramp-password-prompt-regexp tramp-multi-action-password)
--- 1327,1354 ----
  Whenever a pattern matches, the corresponding action is performed.
  Each item looks like (PATTERN ACTION).
  
! The PATTERN should be a form.  This form must evaluate to a
! regular expression to search for.  Note that the regexp must match
! at the end of the buffer except for trailing blanks. When PATTERN
! is evaluated, the symbols `method', `user' and `host' are bound.
  
! The ACTION should be a symbol, a function.  When the corresponding
! PATTERN matches, the ACTION function is called."
    :group 'tramp
!   :type '(repeat (list form function)))
  
  (defcustom tramp-actions-copy-out-of-band
    '((tramp-password-prompt-regexp tramp-action-password)
      (tramp-wrong-passwd-regexp tramp-action-permission-denied)
+     ("\\(.+: Permission denied\\)" tramp-action-copy-failed)
+     ("\\(.+: \\(not a regular file\\|is a directory\\)\\)" tramp-action-copy-failed)
+     ("\\(.+: No such file or directory\\)" tramp-action-copy-failed)
      (tramp-process-alive-regexp tramp-action-out-of-band))
    "List of pattern/action pairs.
  This list is used for copying/renaming with out-of-band methods.
  See `tramp-actions-before-shell' for more info."
    :group 'tramp
!   :type '(repeat (list form function)))
  
  (defcustom tramp-multi-actions
    '((tramp-password-prompt-regexp tramp-multi-action-password)
***************
*** 1358,1364 ****
  This list is used for each hop in multi-hop connections.
  See `tramp-actions-before-shell' for more info."
    :group 'tramp
!   :type '(repeat (list variable function)))
  
  (defcustom tramp-initial-commands
    '("unset HISTORY"
--- 1361,1367 ----
  This list is used for each hop in multi-hop connections.
  See `tramp-actions-before-shell' for more info."
    :group 'tramp
!   :type '(repeat (list form function)))
  
  (defcustom tramp-initial-commands
    '("unset HISTORY"
***************
*** 3174,3185 ****
        (message "Transferring %s to %s..." filename newname)
  
        ;; Use rcp-like program for file transfer.
!       (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf
! 		      copy-program copy-args)))
! 	(tramp-set-process-query-on-exit-flag p nil)
! 	(tramp-process-actions p multi-method method user host
! 			       tramp-actions-copy-out-of-band))
!       (kill-buffer trampbuf)
        (message "Transferring %s to %s...done" filename newname)
  
        ;; Set the mode.
--- 3177,3189 ----
        (message "Transferring %s to %s..." filename newname)
  
        ;; Use rcp-like program for file transfer.
!       (unwind-protect
!           (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf
!                           copy-program copy-args)))
!             (tramp-set-process-query-on-exit-flag p nil)
!             (tramp-process-actions p multi-method method user host
!                                    tramp-actions-copy-out-of-band))
!         (kill-buffer trampbuf))
        (message "Transferring %s to %s...done" filename newname)
  
        ;; Set the mode.
***************
*** 5353,5358 ****
--- 5357,5367 ----
    (kill-process p)
    (throw 'tramp-action 'permission-denied))
  
+ (defun tramp-action-copy-failed (p multi-method method user host)
+   "Signal copy failed."
+   (kill-process p)
+   (error "%s" (match-string 1)))
+ 
  (defun tramp-action-yesno (p multi-method method user host)
    "Ask the user for confirmation using `yes-or-no-p'.
  Send \"yes\" to remote process on confirmation, abort otherwise.
***************
*** 5409,5417 ****
  	       (tramp-message 10 "'set mode' error ignored.")
  	       (tramp-message 9 "Process has finished.")
  	       (throw 'tramp-action 'ok))
- 	   (goto-char (point-min))
- 	   (when (re-search-forward "^.cp.?: \\(.+: Permission denied.?\\)$" nil t)
- 	     (error "Remote host: %s" (match-string 1)))
  	   (tramp-message 9 "Process has died.")
  	   (throw 'tramp-action 'process-died)))
  	(t nil)))
--- 5418,5423 ----
***************
*** 5466,5476 ****
  	(while todo
  	  (goto-char (point-min))
  	  (setq item (pop todo))
! 	  (setq pattern (symbol-value (nth 0 item)))
  	  (setq action (nth 1 item))
  	  (tramp-message 10 "Looking for regexp \"%s\" from remote shell"
  			 pattern)
! 	  (when (re-search-forward (concat pattern "\\'") nil t)
  	    (setq found (funcall action p multi-method method user host)))))
        found)))
  
--- 5472,5482 ----
  	(while todo
  	  (goto-char (point-min))
  	  (setq item (pop todo))
! 	  (setq pattern (eval (nth 0 item)))
  	  (setq action (nth 1 item))
  	  (tramp-message 10 "Looking for regexp \"%s\" from remote shell"
  			 pattern)
! 	  (when (re-search-forward (concat pattern "[ \t\n]*\\'") nil t)
  	    (setq found (funcall action p multi-method method user host)))))
        found)))
  
***************
*** 5503,5509 ****
  	(while todo
  	  (goto-char (point-min))
  	  (setq item (pop todo))
! 	  (setq pattern (symbol-value (nth 0 item)))
  	  (setq action (nth 1 item))
  	  (tramp-message 10 "Looking for regexp \"%s\" from remote shell"
  			 pattern)
--- 5509,5515 ----
  	(while todo
  	  (goto-char (point-min))
  	  (setq item (pop todo))
! 	  (setq pattern (eval (nth 0 item)))
  	  (setq action (nth 1 item))
  	  (tramp-message 10 "Looking for regexp \"%s\" from remote shell"
  			 pattern)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

             reply	other threads:[~2006-11-21 19:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-21 19:22 Lars Hansen [this message]
2006-11-23 21:48 ` Bugfix and improved error handling Michael Albinus
2006-11-24 16:28   ` Lars Hansen
2006-11-24 17:35     ` Michael Albinus
2006-11-24 19:17       ` Lars Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=456351DB.8010805@soem.dk \
    --to=lists@soem.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).