 (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))
 
 (defvar svn-status-partner-buffer nil "The partner buffer for this svn related buffer")
 (make-variable-buffer-local 'svn-status-partner-buffer)

(defun svn-status-base-dir (&optional start-directory)
  "Find the svn root directory for the current working copy.
Return nil, if not in a svn working copy."
  (let* ((base-dir (expand-file-name (or start-directory default-directory)))
         (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)))
    (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)))))
    (and in-tree base-dir)))

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

                           (string= root tree)
                           ;; buffer is modified and in the tree TREE.
                           svn-status-auto-revert-buffers)
                  ;; (message "svn-revert-some-buffers: %s %s" (buffer-file-name) (verify-visited-file-modtime (current-buffer)))
                  ;; Keep the buffer if the file doesn't exist
                  (when (and (file-exists-p file) (not (verify-visited-file-modtime (current-buffer))))
                    (revert-buffer t t)
                    (goto-char point-pos)))))))))))

