 
 ;;;###autoload
 (defun svn-status (dir &optional arg)
+  "Examine the status of Subversion working copy in directory DIR.
+If ARG then pass the -u argument to `svn status'."
   (interactive (list (read-file-name "SVN status directory: "
                                      nil default-directory nil)))
   (unless (file-directory-p dir)
     (error "%s is not a directory" dir))
-  (setq dir (file-name-as-directory dir))
-  (setq svn-status-directory-history (delete dir svn-status-directory-history))
-  (add-to-list 'svn-status-directory-history dir)
-  (unless (string= (buffer-name) "*svn-status*")
-    (message "psvn: Saving initial window configuration")
-    (setq svn-status-initial-window-configuration (current-window-configuration)))
-  (let* ((status-buf (get-buffer-create "*svn-status*"))
-         (proc-buf (get-buffer-create "*svn-process*")))
-    (save-excursion
-      (set-buffer status-buf)
-      (setq default-directory dir)
-      (set-buffer proc-buf)
-      (setq default-directory dir)
-      (if arg
-          (svn-run-svn t t 'status "status" "-vu")
-        (svn-run-svn t t 'status "status" "-v")))))
+    (if (not (file-exists-p (concat dir "/.svn/")))
+        (when (y-or-n-p
+               (concat dir
+                       " does not seem to be a Subversion working copy (no .svn directory).  "
+                       "Run dired instead? "))
+          (dired dir))
+      (setq dir (file-name-as-directory dir))
+      (setq svn-status-directory-history (delete dir svn-status-directory-history))
+      (add-to-list 'svn-status-directory-history dir)
+      (unless (string= (buffer-name) "*svn-status*")
+        (message "psvn: Saving initial window configuration")
+        (setq svn-status-initial-window-configuration (current-window-configuration)))
+      (let* ((status-buf (get-buffer-create "*svn-status*"))
+             (proc-buf (get-buffer-create "*svn-process*")))
+        (save-excursion
+          (set-buffer status-buf)
+          (setq default-directory dir)
+          (set-buffer proc-buf)
+          (setq default-directory dir)
+          (if arg
+              (svn-run-svn t t 'status "status" "-vu")
+            (svn-run-svn t t 'status "status" "-v"))))))
 
 (defun svn-status-use-history ()
   (interactive)

(when (not svn-status-mode-map)
  (setq svn-status-mode-map (make-sparse-keymap))
  (suppress-keymap svn-status-mode-map)
  (define-key svn-status-mode-map [return] 'svn-status-select-line)
  (define-key svn-status-mode-map [?s] 'svn-status-show-process-buffer)
  (define-key svn-status-mode-map [?f] 'svn-status-find-file)
  (define-key svn-status-mode-map [?o] 'svn-status-find-file-other-window)

  (find-file-other-window (svn-status-line-info->filename
                           (svn-status-get-line-information))))

(defun svn-status-find-file-or-examine-directory ()
  "If point is on a directory, run `svn-status' on that directory.
Otherwise run `find-file'."
  (interactive)
  (let ((line-info (svn-status-get-line-information)))
    (if (svn-status-line-info->directory-p line-info)
        (svn-status (svn-status-line-info->full-path line-info))
      (find-file (svn-status-line-info->filename line-info)))))

(defun svn-status-examine-parent ()
  "Run `svn-status' on the parent of the current directory."
  (interactive)
  (svn-status (expand-file-name "../")))

(defun svn-status-line-info->has-usermark (line-info) (nth 0 line-info))
(defun svn-status-line-info->filemark (line-info) (nth 1 line-info))
(defun svn-status-line-info->propmark (line-info) (nth 2 line-info))
