   ;; when running svn on a remote host: expand local file names to get full names to access the file on the remote host via emacs
   (if (file-remote-p default-directory)
       (concat (file-remote-p default-directory) file-name)
+    file-name))
+
+(defun svn-local-filename-for-remote-access (file-name)
+  "Convert a full file name to a local file name that can be used for a local svn invocation."
+  (if (file-remote-p file-name)
+      (tramp-file-name-localname (tramp-dissect-file-name file-name))
     file-name))
 
 (defun svn-process-environment ()

          (while (re-search-forward search-string (point-max) t)
            (replace-match (replace-regexp-in-string " " "-" (match-string 1)) nil nil nil 1)))))))

(defun svn-status-parse-fixup-tramp-exit ()
  "Helper function to handle tramp connections stopping with an exit output.
Add this function to the `svn-pre-parse-status-hook'."
  (goto-char (point-max))
  (when (eq (svn-point-at-bol) (svn-point-at-eol))
    (forward-line -1))
  (beginning-of-line)
  (when (looking-at "exit")
    (delete-region (point) (svn-point-at-eol))))
;;(add-hook 'svn-pre-parse-status-hook 'svn-status-parse-fixup-tramp-exit)

(defun svn-parse-status-result ()
  "Parse the `svn-process-buffer-name' buffer.
The results are used to build the `svn-status-info' variable."

        (goto-char (point-min))
        (while (re-search-forward "\r$" (point-max) t)
          (replace-match "" nil nil))))))

(defun svn-fixup-tramp-exit ()
  "Helper function to handle tramp connections stopping with an exit output."
  (goto-char (point-max))
  (when (eq (svn-point-at-bol) (svn-point-at-eol))
    (forward-line -1))
  (beginning-of-line)
  (when (looking-at "exit")
    (delete-region (point) (svn-point-at-eol))))

(defun svn-fixup-tramp-output-maybe ()
  "Fixup leftover output when running via tramp"
  (when (file-remote-p default-directory)
    (svn-fixup-tramp-exit)))

(condition-case nil
    ;;(easy-menu-add-item nil '("tools") ["SVN Status" svn-status t] "PCL-CVS")
