emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bugfix and improved error handling


From: Lars Hansen
Subject: Bugfix and improved error handling
Date: Tue, 21 Nov 2006 20:22:03 +0100
User-agent: Icedove 1.5.0.7 (X11/20061013)

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?

*** /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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]