;;; vc-svn.el --- non-resident support for Subversion version-control
-;; Copyright (C) 2003-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2013 Free Software Foundation, Inc.
;; Author: FSF (see vc.el for full credits)
;; Maintainer: Stefan Monnier <monnier@gnu.org>
;;; Customization options
;;;
+(defgroup vc-svn nil
+ "VC Subversion (svn) backend."
+ :version "24.1"
+ :group 'vc)
+
;; FIXME there is also svnadmin.
(defcustom vc-svn-program "svn"
"Name of the SVN executable."
:type 'string
- :group 'vc)
+ :group 'vc-svn)
(defcustom vc-svn-global-switches nil
"Global switches to pass to any SVN command."
:value ("")
string))
:version "22.1"
- :group 'vc)
+ :group 'vc-svn)
(defcustom vc-svn-register-switches nil
"Switches for registering a file into SVN.
(string :tag "Argument String")
(repeat :tag "Argument List" :value ("") string))
:version "22.1"
- :group 'vc)
+ :group 'vc-svn)
(defcustom vc-svn-diff-switches
t ;`svn' doesn't support common args like -c or -b.
:value ("")
string))
:version "22.1"
- :group 'vc)
+ :group 'vc-svn)
(defcustom vc-svn-header '("\$Id\$")
"Header keywords to be inserted by `vc-insert-headers'."
:version "24.1" ; no longer consult the obsolete vc-header-alist
:type '(repeat string)
- :group 'vc)
+ :group 'vc-svn)
;; We want to autoload it for use by the autoloaded version of
;; vc-svn-registered, but we want the value to be compiled at startup, not
(vc-svn-command t 0 file "status" (if localp "-v" "-u"))
(vc-svn-parse-status file))))
+;; NB this does not handle svn properties, which can be changed
+;; without changing the file timestamp.
+;; Note that unlike vc-cvs-state-heuristic, this is not called from
+;; vc-svn-state. AFAICS, it is only called from vc-state-refresh via
+;; vc-after-save (bug#7850). Therefore the fact that it ignores
+;; properties is irrelevant. If you want to make vc-svn-state call
+;; this, it should be extended to handle svn properties.
(defun vc-svn-state-heuristic (file)
"SVN-specific state heuristic."
- (vc-svn-state file 'local))
+ ;; If the file has not changed since checkout, consider it `up-to-date'.
+ ;; Otherwise consider it `edited'. Copied from vc-cvs-state-heuristic.
+ (let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
+ (lastmod (nth 5 (file-attributes file))))
+ (cond
+ ((equal checkout-time lastmod) 'up-to-date)
+ ((string= (vc-working-revision file) "0") 'added)
+ ((null checkout-time) 'unregistered)
+ (t 'edited))))
;; FIXME it would be better not to have the "remote" argument,
;; but to distinguish the two output formats based on content.
(defun vc-svn-create-repo ()
"Create a new SVN repository."
(vc-do-command "*vc*" 0 "svnadmin" '("create" "SVN"))
- (vc-do-command "*vc*" 0 vc-svn-program '(".")
- "checkout" (concat "file://" default-directory "SVN")))
+ (vc-svn-command "*vc*" 0 "." "checkout"
+ (concat "file://" default-directory "SVN")))
(defun vc-svn-register (files &optional rev comment)
"Register FILES into the SVN version-control system.
;; Check out a particular version (or recreate the file).
(vc-file-setprop file 'vc-working-revision nil)
(apply 'vc-svn-command nil 0 file
- "--non-interactive" ; bug#4280
"update"
(cond
((null rev) "-rBASE")
(message "Merging changes into %s..." file)
;; (vc-file-setprop file 'vc-working-revision nil)
(vc-file-setprop file 'vc-checkout-time 0)
- (vc-svn-command nil 0 file "--non-interactive" "update") ; see bug#7152
+ (vc-svn-command nil 0 file "update")
;; Analyze the merge result reported by SVN, and set
;; file properties accordingly.
(with-current-buffer (get-buffer "*vc*")
;; 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)))
+ (regexp-quote (file-relative-name file)))
nil t)
(cond
;; Merge successful, we are in sync with repository now
or svn+ssh://."
(let (tempfile host remotefile directory fileurl-p)
(with-temp-buffer
- (vc-do-command (current-buffer) 0 vc-svn-program nil "info")
+ (vc-svn-command (current-buffer) 0 nil "info")
(goto-char (point-min))
(unless (re-search-forward "Repository Root: \\(file://\\(/.*\\)\\)\\|\\(svn\\+ssh://\\([^/]+\\)\\(/.*\\)\\)" nil t)
(error "Repository information is unavailable"))
(defun vc-svn-command (buffer okstatus file-or-list &rest flags)
"A wrapper around `vc-do-command' for use in vc-svn.el.
The difference to vc-do-command is that this function always invokes `svn',
-and that it passes `vc-svn-global-switches' to it before FLAGS."
- (apply 'vc-do-command (or buffer "*vc*") okstatus vc-svn-program file-or-list
- (if (stringp vc-svn-global-switches)
+and that it passes \"--non-interactive\" and `vc-svn-global-switches' to
+it before FLAGS."
+ ;; Might be nice if svn defaulted to non-interactive if stdin not tty.
+ ;; http://svn.haxx.se/dev/archive-2008-05/0762.shtml
+ ;; http://svn.haxx.se/dev/archive-2009-04/0094.shtml
+ ;; Maybe newer ones do?
+ (or (member "--non-interactive"
+ (setq flags (if (stringp vc-svn-global-switches)
(cons vc-svn-global-switches flags)
- (append vc-svn-global-switches
- flags))))
+ (append vc-svn-global-switches flags))))
+ (setq flags (cons "--non-interactive" flags)))
+ (apply 'vc-do-command (or buffer "*vc*") okstatus vc-svn-program file-or-list
+ flags))
(defun vc-svn-repository-hostname (dirname)
(with-temp-buffer
(vc-svn-command buf 'async file "annotate" (if rev (concat "-r" rev))))
(defun vc-svn-annotate-time-of-rev (rev)
- ;; Arbitrarily assume 10 commmits per day.
+ ;; Arbitrarily assume 10 commits per day.
(/ (string-to-number rev) 10.0))
(defvar vc-annotate-parent-rev)