         base-dir
       ;; (message "calculating base-dir for %s" start-dir)
       (svn-compute-svn-client-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)))
-        ;; (message "repository-root: %s start-dir: %s" repository-root start-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)))
-                   ;; (message "base-dir: %s, dir-below: %s, dot-svn-dir: %s in-tree: %s" base-dir dir-below dot-svn-dir in-tree)
-                   (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))))
+      ;; (message "repository-root: %s start-dir: %s" repository-root start-dir)
+      (cond
+       ((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
+       ((and (<= (car svn-client-version) 1) (< (cadr svn-client-version) 7))
+        (setq base-dir (svn-status-base-dir-for-old-svn-client start-dir))) ;; svn version < 1.7
+       (t
+        (setq base-dir (svn-status-base-dir-1 start-dir))))
+      (when 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-1 (&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.7 and up."
+  (let ((default-directory (if start-directory
+                               (expand-file-name start-directory)
+                             (symbol-value 'default-directory)))
+        parent
+        wc-root)
+    (when (svn-version-controlled-dir-p default-directory)
+      (svn-status-parse-info t)
+      (setq wc-root (file-name-as-directory (plist-get svn-status-base-info :working-copy-root-path)))
+      (when wc-root
+        ;; traversing up the hierarchy shortens the path name. Stop if
+        ;; it doesn't, e.g we reached / already.
+        (setq parent (expand-file-name (concat wc-root "..")))
+        (or (and (< (length parent) (length wc-root))
+                 (svn-status-base-dir-1 (expand-file-name (concat wc-root ".."))))
+            wc-root)))))
+
+(defun svn-status-base-dir-for-old-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.6 and below."
+  (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)))
+             ;; (message "base-dir: %s, dir-below: %s, dot-svn-dir: %s in-tree: %s" base-dir dir-below dot-svn-dir in-tree)
+             (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-base-dir-for-ancient-svn-client (&optional start-directory)
   "Find the svn root directory for the current working copy.

    (with-current-buffer (get-buffer-create svn-process-buffer-name)
      (setq old-process-default-dir default-directory)
      (setq default-directory directory)) ;; update the default-directory for the *svn-process* buffer
  (svn-run nil t 'parse-info "info" ".")
  (with-current-buffer svn-process-buffer-name
    ;; (message "svn-status-repo-for-path: %s: default-directory: %s directory: %s old-process-default-dir: %s" svn-process-buffer-name default-directory directory old-process-default-dir)
    (setq default-directory old-process-default-dir)
    (goto-char (point-min))
    (let ((case-fold-search t))
      (if (search-forward "repository root: " nil t)
          (buffer-substring-no-properties (point) (svn-point-at-eol))
        (when (search-forward "repository uuid: " nil t)
          (message "psvn.el: Detected an old svn working copy in '%s'. Please check it out again to get a 'Repository Root' entry in the svn info output."
                   default-directory)
          (concat "Svn Repo UUID: " (buffer-substring-no-properties (point) (svn-point-at-eol)))))))))

(defun svn-status-base-dir (&optional start-directory)
  "Find the svn root directory for the current working copy.

(defun svn-status-parse-info-result ()
  "Parse the result from the svn info command.
Put the found values in `svn-status-base-info'."
  (save-excursion
    (setq svn-status-base-info ())
    (set-buffer svn-process-buffer-name)
    (goto-char (point-min))
    (let ((case-fold-search t)
          (key)
          (val))
      (loop while (looking-at "\\(.*?\\)\\s-*:\\s-*\\(.*\\)$")
        do (setq key (intern (concat ":" (downcase (subst-char-in-string ?\  ?- (match-string 1))))))
        (setq val (match-string 2))
        (setq svn-status-base-info (plist-put svn-status-base-info
                                              key val))
        until (< 0 (forward-line))))))

(defun svn-status-base-info->url ()
  "Extract the url part from `svn-status-base-info'."
  (plist-get svn-status-base-info :url))

(defun svn-status-base-info->repository-root ()
  "Extract the repository-root part from `svn-status-base-info'."
  (plist-get svn-status-base-info :repository-root))

(defun svn-status-checkout-prefix-path ()
  "When only a part of the svn repository is checked out, return the file path for this checkout."
