 
 ;;; Code:
 
-(defconst svn-psvn-revision "2012-03-26, 21:23:49" "The revision date of psvn.")
+(defconst svn-psvn-revision "2015-07-20, 21:42:00" "The revision date of psvn.")
 
 
 (require 'easymenu)

(defun svn-checkout (repos-url path)
  "Run svn checkout REPOS-URL PATH."
  (interactive (list (read-string "Checkout from repository Url: ")
                     (svn-read-directory-name "Checkout to directory: ")))
  (svn-run t t 'checkout "checkout" repos-url (expand-file-name path)))

;;;###autoload (defalias 'svn-examine 'svn-status)
(defalias 'svn-examine 'svn-status)

;;;###autoload
(defun svn-status (dir &optional arg)

        base-dir
      ;; (message "calculating base-dir for %s" start-dir)
      (svn-compute-svn-client-version)
      ;; (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.
