all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Bugfix and improved error handling
@ 2006-11-21 19:22 Lars Hansen
  2006-11-23 21:48 ` Michael Albinus
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Hansen @ 2006-11-21 19:22 UTC (permalink / 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-11-24 19:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-21 19:22 Bugfix and improved error handling Lars Hansen
2006-11-23 21:48 ` Michael Albinus
2006-11-24 16:28   ` Lars Hansen
2006-11-24 17:35     ` Michael Albinus
2006-11-24 19:17       ` Lars Hansen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.