           (let ((file (buffer-file-name)))
             (when file
               (let ((root (svn-status-base-dir (file-name-directory file))))
+                ;; (message "svn-status-save-some-buffers: file: %s, root: %s" file root)
                 (when (and root
                            (string= root tree)
                            ;; buffer is modified and in the tree TREE.

                   (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)))


(defun svn-status-repo-for-path (directory)
  "Find the repository root for DIRECTORY."
  (let ((old-process-default-dir))
    (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))
      (when (search-forward "repository root: " nil t)
        (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.
