;;; vc-svn.el --- non-resident support for Subversion version-control
-;; Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Stefan Monnier <monnier@gnu.org>
;; :group 'vc
)
+(defvar vc-svn-admin-directory
+ (cond ((and (eq system-type 'windows-nt)
+ (getenv "SVN_ASP_DOT_NET_HACK"))
+ "_svn")
+ (t ".svn"))
+ "The name of the \".svn\" subdirectory or its equivalent.")
+
;;;
;;; State-querying functions
;;;
+;;; vc-svn-admin-directory is generally not defined when the
+;;; autoloaded function is called.
+
;;;###autoload (defun vc-svn-registered (f)
-;;;###autoload (when (file-readable-p (expand-file-name
-;;;###autoload ".svn/entries" (file-name-directory f)))
+;;;###autoload (let ((admin-dir (cond ((and (eq system-type 'windows-nt)
+;;;###autoload (getenv "SVN_ASP_DOT_NET_HACK"))
+;;;###autoload "_svn")
+;;;###autoload (t ".svn"))))
+;;;###autoload (when (file-readable-p (expand-file-name
+;;;###autoload (concat admin-dir "/entries")
+;;;###autoload (file-name-directory f)))
;;;###autoload (load "vc-svn")
-;;;###autoload (vc-svn-registered f)))
+;;;###autoload (vc-svn-registered f))))
;;;###autoload
(add-to-list 'completion-ignored-extensions ".svn/")
(defun vc-svn-registered (file)
"Check if FILE is SVN registered."
- (when (file-readable-p (expand-file-name ".svn/entries"
+ (when (file-readable-p (expand-file-name (concat vc-svn-admin-directory
+ "/entries")
(file-name-directory file)))
(with-temp-buffer
(cd (file-name-directory file))
;; an `error' by vc-do-command.
(error nil))))
(when (eq 0 status)
- (vc-svn-parse-status t)
- (eq 'SVN (vc-file-getprop file 'vc-backend)))))))
+ (vc-svn-parse-status file))))))
(defun vc-svn-state (file &optional localp)
"SVN-specific version of `vc-state'."
(with-temp-buffer
(cd (file-name-directory file))
(vc-svn-command t 0 file "status" (if localp "-v" "-u"))
- (vc-svn-parse-status localp)
- (vc-file-getprop file 'vc-state)))
+ (vc-svn-parse-status file)))
(defun vc-svn-state-heuristic (file)
"SVN-specific state heuristic."
;; enough. Otherwise it might fail with remote repositories.
(with-temp-buffer
(vc-svn-command t 0 nil "status" (if localp "-v" "-u"))
- (vc-svn-parse-status localp))))
+ (vc-svn-parse-status))))
(defun vc-svn-workfile-version (file)
"SVN-specific version of `vc-workfile-version'."
(defun vc-svn-responsible-p (file)
"Return non-nil if SVN thinks it is responsible for FILE."
- (file-directory-p (expand-file-name ".svn"
+ (file-directory-p (expand-file-name vc-svn-admin-directory
(if (file-directory-p file)
file
(file-name-directory file)))))
(if (looking-at "At revision")
0 ;; there were no news; indicate success
(if (re-search-forward
- (concat "^\\([CGDU] \\)?"
+ ;; Newer SVN clients have 3 columns of chars (one for the
+ ;; file's contents, then second for its properties, and the
+ ;; third for lock-grabbing info), before the 2 spaces.
+ ;; We also used to match the filename in column 0 without any
+ ;; meta-info before it, but I believe this can never happen.
+ (concat "^\\(\\([ACGDU]\\)\\(.[B ]\\)? \\)"
(regexp-quote (file-name-nondirectory file)))
nil t)
(cond
;; Merge successful, we are in sync with repository now
- ((string= (match-string 1) "U ")
+ ((string= (match-string 2) "U")
(vc-file-setprop file 'vc-state 'up-to-date)
(vc-file-setprop file 'vc-checkout-time
(nth 5 (file-attributes file)))
0);; indicate success to the caller
;; Merge successful, but our own changes are still in the file
- ((string= (match-string 1) "G ")
+ ((string= (match-string 2) "G")
(vc-file-setprop file 'vc-state 'edited)
0);; indicate success to the caller
;; Conflicts detected!
(let ((coding-system-for-read
(or file-name-coding-system
default-file-name-coding-system)))
- (vc-insert-file (expand-file-name ".svn/entries" dirname)))
+ (vc-insert-file (expand-file-name (concat vc-svn-admin-directory
+ "/entries")
+ dirname)))
(goto-char (point-min))
(when (re-search-forward
- ;; Old `svn' used name="svn:dir", newer use just name="".
+ ;; Old `svn' used name="svn:this_dir", newer use just name="".
(concat "name=\"\\(?:svn:this_dir\\)?\"[\n\t ]*"
"\\(?:[-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
"url=\"\\([^\"]+\\)\"") nil t)
;; behavior for different modules on the same server.
(match-string 1))))
-(defun vc-svn-parse-status (localp)
+(defun vc-svn-parse-status (&optional filename)
"Parse output of \"svn status\" command in the current buffer.
-Set file properties accordingly. Unless FULL is t, parse only
-essential information."
+Set file properties accordingly. Unless FILENAME is non-nil, parse only
+information about FILENAME and return its status."
(let (file status)
(goto-char (point-min))
(while (re-search-forward
- "^[ ADMCI?!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t)
- (setq file (expand-file-name
- (buffer-substring (point) (line-end-position))))
+ ;; Ignore the files with status in [IX?].
+ "^[ ACDGMR!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t)
+ ;; If the username contains spaces, the output format is ambiguous,
+ ;; so don't trust the output's filename unless we have to.
+ (setq file (or filename
+ (expand-file-name
+ (buffer-substring (point) (line-end-position)))))
(setq status (char-after (line-beginning-position)))
(unless (eq status ??)
- (vc-file-setprop file 'vc-backend 'SVN)
+ ;; `vc-BACKEND-registered' must not set vc-backend,
+ ;; which is instead set in vc-registered.
+ (unless filename (vc-file-setprop file 'vc-backend 'SVN))
;; Use the last-modified revision, so that searching in vc-print-log
;; output works.
(vc-file-setprop file 'vc-workfile-version (match-string 3))
(if (eq (char-after (match-beginning 1)) ?*)
'needs-merge
'edited))
- (t 'edited)))))))
+ (t 'edited)))))
+ (if filename (vc-file-getprop filename 'vc-state))))
(defun vc-svn-dir-state-heuristic (dir)
"Find the SVN state of all files in DIR, using only local information."