     (svn-log-view-mode)))
 
 (defun svn-status-version ()
-  "Show the version numbers for psvn.el and the svn command line client"
+  "Show the version numbers for psvn.el and the svn command line client.
+The version number of the client is cached in `svn-client-version'."
   (interactive)
   (let ((window-conf (current-window-configuration))
         (version-string))

(defvar svn-admin-last-repository-dir nil "The last repository url for various operations.")
(defvar svn-last-cmd-ring (make-ring 30) "Ring that holds the last executed svn commands (for debugging purposes)")
(defvar svn-status-cached-version-string nil)
(defvar svn-status-get-line-information-for-file nil)
(defvar svn-status-base-dir-cache (make-hash-table :test 'equal :weakness nil))


    (if (not (eq base-dir 'not-found))
        base-dir
      ;; (message "calculating base-dir for %s" start-dir)
      (unless svn-client-version
        (svn-status-version))
      (let* ((base-dir start-dir)
             (repository-root (svn-status-repo-for-path base-dir))
             (dot-svn-dir (concat base-dir (svn-wc-adm-dir-name)))
             (in-tree (and repository-root (file-exists-p dot-svn-dir)))
             (dir-below (expand-file-name base-dir)))
        (if (and (<= (car svn-client-version) 1) (< (cadr svn-client-version) 3))
            (setq base-dir (svn-status-base-dir-for-ancient-svn-client start-dir)) ;; svn version < 1.3
          (while (when (and dir-below (file-exists-p dot-svn-dir))
                   (setq base-dir (file-name-directory dot-svn-dir))
                   (string-match "\\(.+/\\).+/" dir-below)
                   (setq dir-below
                         (and (string-match "\\(.*/\\)[^/]+/" dir-below)
                              (match-string 1 dir-below)))
                   (when dir-below
                     (if (string= (svn-status-repo-for-path dir-below) repository-root)
                         (setq dot-svn-dir (concat dir-below (svn-wc-adm-dir-name)))
                       (setq dir-below nil)))))
          (setq base-dir (and in-tree base-dir)))
        (svn-puthash start-dir base-dir svn-status-base-dir-cache)
        (svn-status-message 7 "svn-status-base-dir %s => %s" start-dir base-dir)
        base-dir))))

(defun svn-status-base-dir-for-ancient-svn-client (&optional start-directory)
  "Find the svn root directory for the current working copy.
Return nil, if not in a svn working copy.
This function is used for svn clients version 1.2 and below."
  (let* ((base-dir (expand-file-name (or start-directory default-directory)))
         (dot-svn-dir (concat base-dir (svn-wc-adm-dir-name)))
         (in-tree (file-exists-p dot-svn-dir))
         (dir-below (expand-file-name default-directory)))
    (while (when (and dir-below (file-exists-p dot-svn-dir))
             (setq base-dir (file-name-directory dot-svn-dir))
             (string-match "\\(.+/\\).+/" dir-below)
             (setq dir-below
                   (and (string-match "\\(.*/\\)[^/]+/" dir-below)
                        (match-string 1 dir-below)))
             (setq dot-svn-dir (concat dir-below (svn-wc-adm-dir-name)))))
    (and in-tree base-dir)))

(defun svn-status-save-state ()
  "Save psvn persistent options for this working copy to a file."
