($(TRES)): Use literal "../nt/emacs.rc" instead of $(ALL_DEPS).
[bpt/emacs.git] / lisp / vc-svn.el
CommitLineData
1fd3454a
SM
1;;; vc-svn.el --- non-resident support for Subversion version-control
2
c45b3be3 3;; Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
1fd3454a
SM
4
5;; Author: FSF (see vc.el for full credits)
6;; Maintainer: Stefan Monnier <monnier@gnu.org>
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs; see the file COPYING. If not, write to the
086add15
LK
22;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23;; Boston, MA 02110-1301, USA.
1fd3454a
SM
24
25;;; Commentary:
26
27;; This is preliminary support for Subversion (http://subversion.tigris.org/).
28;; It started as `sed s/cvs/svn/ vc.cvs.el' (from version 1.56)
29;; and hasn't been completely fixed since.
30
31;; Sync'd with Subversion's vc-svn.el as of revision 5801.
32
33;;; Bugs:
34
fd140743 35;; - VC-dired is (really) slow.
1fd3454a
SM
36
37;;; Code:
38
39(eval-when-compile
40 (require 'vc))
41
42;;;
43;;; Customization options
44;;;
45
46(defcustom vc-svn-global-switches nil
47 "*Global switches to pass to any SVN command."
48 :type '(choice (const :tag "None" nil)
49 (string :tag "Argument String")
50 (repeat :tag "Argument List"
51 :value ("")
52 string))
bf247b6e 53 :version "22.1"
1fd3454a
SM
54 :group 'vc)
55
56(defcustom vc-svn-register-switches nil
57 "*Extra switches for registering a file into SVN.
58A string or list of strings passed to the checkin program by
59\\[vc-register]."
60 :type '(choice (const :tag "None" nil)
61 (string :tag "Argument String")
62 (repeat :tag "Argument List"
63 :value ("")
64 string))
bf247b6e 65 :version "22.1"
1fd3454a
SM
66 :group 'vc)
67
8462aca5
SM
68(defcustom vc-svn-diff-switches
69 t ;`svn' doesn't support common args like -c or -b.
70 "String or list of strings specifying extra switches for svn diff under VC.
71If nil, use the value of `vc-diff-switches'.
72If you want to force an empty list of arguments, use t."
73 :type '(choice (const :tag "Unspecified" nil)
74 (const :tag "None" t)
1fd3454a
SM
75 (string :tag "Argument String")
76 (repeat :tag "Argument List"
77 :value ("")
78 string))
bf247b6e 79 :version "22.1"
1fd3454a
SM
80 :group 'vc)
81
82(defcustom vc-svn-header (or (cdr (assoc 'SVN vc-header-alist)) '("\$Id\$"))
83 "*Header keywords to be inserted by `vc-insert-headers'."
bf247b6e 84 :version "22.1"
1fd3454a
SM
85 :type '(repeat string)
86 :group 'vc)
87
5cc7cb96
SM
88(defconst vc-svn-use-edit nil
89 ;; Subversion does not provide this feature (yet).
1fd3454a
SM
90 "*Non-nil means to use `svn edit' to \"check out\" a file.
91This is only meaningful if you don't use the implicit checkout model
92\(i.e. if you have $SVNREAD set)."
5cc7cb96 93 ;; :type 'boolean
bf247b6e 94 ;; :version "22.1"
5cc7cb96
SM
95 ;; :group 'vc
96 )
1fd3454a 97
ace2fad9
CY
98(defvar vc-svn-admin-directory
99 (cond ((and (eq system-type 'windows-nt)
100 (getenv "SVN_ASP_DOT_NET_HACK"))
101 "_svn")
102 (t ".svn"))
103 "The name of the \".svn\" subdirectory or its equivalent.")
104
1fd3454a
SM
105;;;
106;;; State-querying functions
107;;;
108
ace2fad9
CY
109;;; vc-svn-admin-directory is generally not defined when the
110;;; autoloaded function is called.
111
1fd3454a 112;;;###autoload (defun vc-svn-registered (f)
ace2fad9
CY
113;;;###autoload (let ((admin-dir (cond ((and (eq system-type 'windows-nt)
114;;;###autoload (getenv "SVN_ASP_DOT_NET_HACK"))
115;;;###autoload "_svn")
116;;;###autoload (t ".svn"))))
117;;;###autoload (when (file-readable-p (expand-file-name
118;;;###autoload (concat admin-dir "/entries")
119;;;###autoload (file-name-directory f)))
1fd3454a 120;;;###autoload (load "vc-svn")
ace2fad9 121;;;###autoload (vc-svn-registered f))))
1fd3454a 122
3bdc13e4
SM
123;;;###autoload
124(add-to-list 'completion-ignored-extensions ".svn/")
125
1fd3454a
SM
126(defun vc-svn-registered (file)
127 "Check if FILE is SVN registered."
ace2fad9
CY
128 (when (file-readable-p (expand-file-name (concat vc-svn-admin-directory
129 "/entries")
1fd3454a
SM
130 (file-name-directory file)))
131 (with-temp-buffer
132 (cd (file-name-directory file))
aaef169d 133 (let ((status
df4da7f4
SM
134 (condition-case nil
135 ;; Ignore all errors.
136 (vc-svn-command t t file "status" "-v")
137 ;; Some problem happened. E.g. We can't find an `svn'
138 ;; executable. We used to only catch `file-error' but when
139 ;; the process is run on a remote host via Tramp, the error
140 ;; is only reported via the exit status which is turned into
141 ;; an `error' by vc-do-command.
142 (error nil))))
143 (when (eq 0 status)
bc8c1bb4 144 (vc-svn-parse-status file))))))
1fd3454a
SM
145
146(defun vc-svn-state (file &optional localp)
147 "SVN-specific version of `vc-state'."
7ffc77d3 148 (setq localp (or localp (vc-stay-local-p file)))
1fd3454a
SM
149 (with-temp-buffer
150 (cd (file-name-directory file))
151 (vc-svn-command t 0 file "status" (if localp "-v" "-u"))
bc8c1bb4 152 (vc-svn-parse-status file)))
1fd3454a
SM
153
154(defun vc-svn-state-heuristic (file)
155 "SVN-specific state heuristic."
156 (vc-svn-state file 'local))
157
158(defun vc-svn-dir-state (dir &optional localp)
159 "Find the SVN state of all files in DIR."
7ffc77d3 160 (setq localp (or localp (vc-stay-local-p dir)))
1fd3454a
SM
161 (let ((default-directory dir))
162 ;; Don't specify DIR in this command, the default-directory is
163 ;; enough. Otherwise it might fail with remote repositories.
164 (with-temp-buffer
165 (vc-svn-command t 0 nil "status" (if localp "-v" "-u"))
bc8c1bb4 166 (vc-svn-parse-status))))
1fd3454a
SM
167
168(defun vc-svn-workfile-version (file)
169 "SVN-specific version of `vc-workfile-version'."
170 ;; There is no need to consult RCS headers under SVN, because we
171 ;; get the workfile version for free when we recognize that a file
172 ;; is registered in SVN.
173 (vc-svn-registered file)
174 (vc-file-getprop file 'vc-workfile-version))
175
176(defun vc-svn-checkout-model (file)
177 "SVN-specific version of `vc-checkout-model'."
178 ;; It looks like Subversion has no equivalent of CVSREAD.
179 'implicit)
180
5cc7cb96
SM
181;; vc-svn-mode-line-string doesn't exist because the default implementation
182;; works just fine.
183
1fd3454a
SM
184(defun vc-svn-dired-state-info (file)
185 "SVN-specific version of `vc-dired-state-info'."
fd140743
SM
186 (let ((svn-state (vc-state file)))
187 (cond ((eq svn-state 'edited)
188 (if (equal (vc-workfile-version file) "0")
189 "(added)" "(modified)"))
190 ((eq svn-state 'needs-patch) "(patch)")
191 ((eq svn-state 'needs-merge) "(merge)"))))
1fd3454a 192
cbbd2cd3
TTN
193(defun vc-svn-previous-version (file rev)
194 (let ((newrev (1- (string-to-number rev))))
195 (when (< 0 newrev)
196 (number-to-string newrev))))
197
198(defun vc-svn-next-version (file rev)
199 (let ((newrev (1+ (string-to-number rev))))
200 ;; The "workfile version" is an uneasy conceptual fit under Subversion;
201 ;; we use it as the upper bound until a better idea comes along. If the
202 ;; workfile version W coincides with the tree's latest revision R, then
203 ;; this check prevents a "no such revision: R+1" error. Otherwise, it
204 ;; inhibits showing of W+1 through R, which could be considered anywhere
205 ;; from gracious to impolite.
206 (unless (< (string-to-number (vc-file-getprop file 'vc-workfile-version))
207 newrev)
208 (number-to-string newrev))))
209
1fd3454a
SM
210
211;;;
212;;; State-changing functions
213;;;
214
215(defun vc-svn-register (file &optional rev comment)
216 "Register FILE into the SVN version-control system.
217COMMENT can be used to provide an initial description of FILE.
218
219`vc-register-switches' and `vc-svn-register-switches' are passed to
220the SVN command (in that order)."
5cc7cb96 221 (apply 'vc-svn-command nil 0 file "add" (vc-switches 'SVN 'register)))
1fd3454a
SM
222
223(defun vc-svn-responsible-p (file)
224 "Return non-nil if SVN thinks it is responsible for FILE."
ace2fad9 225 (file-directory-p (expand-file-name vc-svn-admin-directory
1fd3454a
SM
226 (if (file-directory-p file)
227 file
228 (file-name-directory file)))))
229
230(defalias 'vc-svn-could-register 'vc-svn-responsible-p
231 "Return non-nil if FILE could be registered in SVN.
232This is only possible if SVN is responsible for FILE's directory.")
233
234(defun vc-svn-checkin (file rev comment)
235 "SVN-specific version of `vc-backend-checkin'."
5129f10c
KF
236 (let ((status (apply
237 'vc-svn-command nil 1 file "ci"
238 (nconc (list "-m" comment) (vc-switches 'SVN 'checkin)))))
1fd3454a
SM
239 (set-buffer "*vc*")
240 (goto-char (point-min))
241 (unless (equal status 0)
242 ;; Check checkin problem.
243 (cond
fd140743 244 ((search-forward "Transaction is out of date" nil t)
1fd3454a
SM
245 (vc-file-setprop file 'vc-state 'needs-merge)
246 (error (substitute-command-keys
247 (concat "Up-to-date check failed: "
248 "type \\[vc-next-action] to merge in changes"))))
249 (t
250 (pop-to-buffer (current-buffer))
251 (goto-char (point-min))
252 (shrink-window-if-larger-than-buffer)
253 (error "Check-in failed"))))
254 ;; Update file properties
255 ;; (vc-file-setprop
256 ;; file 'vc-workfile-version
257 ;; (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
258 ))
259
260(defun vc-svn-find-version (file rev buffer)
261 (apply 'vc-svn-command
262 buffer 0 file
263 "cat"
264 (and rev (not (string= rev ""))
265 (concat "-r" rev))
fd140743 266 (vc-switches 'SVN 'checkout)))
1fd3454a
SM
267
268(defun vc-svn-checkout (file &optional editable rev)
269 (message "Checking out %s..." file)
270 (with-current-buffer (or (get-file-buffer file) (current-buffer))
fd140743 271 (vc-call update file editable rev (vc-switches 'SVN 'checkout)))
1fd3454a
SM
272 (vc-mode-line file)
273 (message "Checking out %s...done" file))
274
275(defun vc-svn-update (file editable rev switches)
276 (if (and (file-exists-p file) (not rev))
277 ;; If no revision was specified, just make the file writable
278 ;; if necessary (using `svn-edit' if requested).
279 (and editable (not (eq (vc-svn-checkout-model file) 'implicit))
280 (if vc-svn-use-edit
281 (vc-svn-command nil 0 file "edit")
282 (set-file-modes file (logior (file-modes file) 128))
283 (if (equal file buffer-file-name) (toggle-read-only -1))))
284 ;; Check out a particular version (or recreate the file).
285 (vc-file-setprop file 'vc-workfile-version nil)
286 (apply 'vc-svn-command nil 0 file
1fd3454a
SM
287 "update"
288 ;; default for verbose checkout: clear the sticky tag so
289 ;; that the actual update will get the head of the trunk
5cc7cb96
SM
290 (cond
291 ((null rev) "-rBASE")
292 ((or (eq rev t) (equal rev "")) nil)
293 (t (concat "-r" rev)))
1fd3454a
SM
294 switches)))
295
3bdc13e4
SM
296(defun vc-svn-delete-file (file)
297 (vc-svn-command nil 0 file "remove"))
298
2766aaaf
SM
299(defun vc-svn-rename-file (old new)
300 (vc-svn-command nil 0 new "move" (file-relative-name old)))
301
1fd3454a
SM
302(defun vc-svn-revert (file &optional contents-done)
303 "Revert FILE to the version it was based on."
304 (unless contents-done
305 (vc-svn-command nil 0 file "revert"))
306 (unless (eq (vc-checkout-model file) 'implicit)
307 (if vc-svn-use-edit
308 (vc-svn-command nil 0 file "unedit")
309 ;; Make the file read-only by switching off all w-bits
310 (set-file-modes file (logand (file-modes file) 3950)))))
311
312(defun vc-svn-merge (file first-version &optional second-version)
313 "Merge changes into current working copy of FILE.
314The changes are between FIRST-VERSION and SECOND-VERSION."
315 (vc-svn-command nil 0 file
c217cb04 316 "merge"
02610d0e 317 "-r" (if second-version
c217cb04
SM
318 (concat first-version ":" second-version)
319 first-version))
1fd3454a
SM
320 (vc-file-setprop file 'vc-state 'edited)
321 (with-current-buffer (get-buffer "*vc*")
322 (goto-char (point-min))
c217cb04
SM
323 (if (looking-at "C ")
324 1 ; signal conflict
1fd3454a
SM
325 0))) ; signal success
326
327(defun vc-svn-merge-news (file)
328 "Merge in any new changes made to FILE."
329 (message "Merging changes into %s..." file)
330 ;; (vc-file-setprop file 'vc-workfile-version nil)
331 (vc-file-setprop file 'vc-checkout-time 0)
332 (vc-svn-command nil 0 file "update")
333 ;; Analyze the merge result reported by SVN, and set
334 ;; file properties accordingly.
335 (with-current-buffer (get-buffer "*vc*")
336 (goto-char (point-min))
337 ;; get new workfile version
338 (if (re-search-forward
1468d754
SM
339 "^\\(Updated to\\|At\\) revision \\([0-9]+\\)" nil t)
340 (vc-file-setprop file 'vc-workfile-version (match-string 2))
1fd3454a
SM
341 (vc-file-setprop file 'vc-workfile-version nil))
342 ;; get file status
1468d754 343 (goto-char (point-min))
1fd3454a 344 (prog1
1468d754 345 (if (looking-at "At revision")
1fd3454a
SM
346 0 ;; there were no news; indicate success
347 (if (re-search-forward
1468d754
SM
348 (concat "^\\([CGDU] \\)?"
349 (regexp-quote (file-name-nondirectory file)))
1fd3454a
SM
350 nil t)
351 (cond
352 ;; Merge successful, we are in sync with repository now
1468d754 353 ((string= (match-string 1) "U ")
1fd3454a
SM
354 (vc-file-setprop file 'vc-state 'up-to-date)
355 (vc-file-setprop file 'vc-checkout-time
356 (nth 5 (file-attributes file)))
357 0);; indicate success to the caller
358 ;; Merge successful, but our own changes are still in the file
1468d754 359 ((string= (match-string 1) "G ")
1fd3454a
SM
360 (vc-file-setprop file 'vc-state 'edited)
361 0);; indicate success to the caller
362 ;; Conflicts detected!
363 (t
364 (vc-file-setprop file 'vc-state 'edited)
365 1);; signal the error to the caller
366 )
367 (pop-to-buffer "*vc*")
368 (error "Couldn't analyze svn update result")))
369 (message "Merging changes into %s...done" file))))
370
371
372;;;
373;;; History functions
374;;;
375
b349012b 376(defun vc-svn-print-log (file &optional buffer)
1fd3454a
SM
377 "Get change log associated with FILE."
378 (save-current-buffer
b349012b 379 (vc-setup-buffer buffer)
1fd3454a
SM
380 (let ((inhibit-read-only t))
381 (goto-char (point-min))
382 ;; Add a line to tell log-view-mode what file this is.
383 (insert "Working file: " (file-relative-name file) "\n"))
384 (vc-svn-command
b349012b 385 buffer
7ffc77d3 386 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
bf54d814
SM
387 file "log"
388 ;; By default Subversion only shows the log upto the working version,
389 ;; whereas we also want the log of the subsequent commits. At least
390 ;; that's what the vc-cvs.el code does.
391 "-rHEAD:0")))
1fd3454a 392
b349012b 393(defun vc-svn-diff (file &optional oldvers newvers buffer)
1fd3454a 394 "Get a difference report using SVN between two versions of FILE."
b349012b 395 (unless buffer (setq buffer "*vc-diff*"))
3625f6b7
SM
396 (if (and oldvers (equal oldvers (vc-workfile-version file)))
397 ;; Use nil rather than the current revision because svn handles it
398 ;; better (i.e. locally).
399 (setq oldvers nil))
fd140743
SM
400 (if (string= (vc-workfile-version file) "0")
401 ;; This file is added but not yet committed; there is no master file.
402 (if (or oldvers newvers)
403 (error "No revisions of %s exist" file)
404 ;; We regard this as "changed".
405 ;; Diff it against /dev/null.
406 ;; Note: this is NOT a "svn diff".
b349012b 407 (apply 'vc-do-command buffer
fd140743
SM
408 1 "diff" file
409 (append (vc-switches nil 'diff) '("/dev/null")))
410 ;; Even if it's empty, it's locally modified.
411 1)
f9d1f3be
SM
412 (let* ((switches
413 (if vc-svn-diff-switches
414 (vc-switches 'SVN 'diff)
415 (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " "))))
2d4e93b9
AS
416 (async (and (not vc-disable-async-diff)
417 (vc-stay-local-p file)
fd140743 418 (or oldvers newvers) ; Svn diffs those locally.
2766aaaf 419 (fboundp 'start-process))))
b349012b 420 (apply 'vc-svn-command buffer
2766aaaf
SM
421 (if async 'async 0)
422 file "diff"
423 (append
f9d1f3be 424 switches
2766aaaf
SM
425 (when oldvers
426 (list "-r" (if newvers (concat oldvers ":" newvers)
427 oldvers)))))
fd140743
SM
428 (if async 1 ; async diff => pessimistic assumption
429 ;; For some reason `svn diff' does not return a useful
430 ;; status w.r.t whether the diff was empty or not.
b349012b 431 (buffer-size (get-buffer buffer))))))
1fd3454a
SM
432
433(defun vc-svn-diff-tree (dir &optional rev1 rev2)
434 "Diff all files at and below DIR."
5cc7cb96 435 (vc-svn-diff (file-name-as-directory dir) rev1 rev2))
1fd3454a
SM
436
437;;;
438;;; Snapshot system
439;;;
440
441(defun vc-svn-create-snapshot (dir name branchp)
442 "Assign to DIR's current version a given NAME.
443If BRANCHP is non-nil, the name is created as a branch (and the current
5cc7cb96
SM
444workspace is immediately moved to that new branch).
445NAME is assumed to be a URL."
446 (vc-svn-command nil 0 dir "copy" name)
447 (when branchp (vc-svn-retrieve-snapshot dir name nil)))
1fd3454a
SM
448
449(defun vc-svn-retrieve-snapshot (dir name update)
450 "Retrieve a snapshot at and below DIR.
451NAME is the name of the snapshot; if it is empty, do a `svn update'.
5cc7cb96
SM
452If UPDATE is non-nil, then update (resynch) any affected buffers.
453NAME is assumed to be a URL."
454 (vc-svn-command nil 0 dir "switch" name)
455 ;; FIXME: parse the output and obey `update'.
456 )
1fd3454a
SM
457
458;;;
459;;; Miscellaneous
460;;;
461
462;; Subversion makes backups for us, so don't bother.
7ffc77d3 463;; (defalias 'vc-svn-make-version-backups-p 'vc-stay-local-p
1fd3454a
SM
464;; "Return non-nil if version backups should be made for FILE.")
465
466(defun vc-svn-check-headers ()
467 "Check if the current file has any headers in it."
468 (save-excursion
469 (goto-char (point-min))
470 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
471\\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
472
473
474;;;
475;;; Internal functions
476;;;
477
478(defun vc-svn-command (buffer okstatus file &rest flags)
479 "A wrapper around `vc-do-command' for use in vc-svn.el.
480The difference to vc-do-command is that this function always invokes `svn',
481and that it passes `vc-svn-global-switches' to it before FLAGS."
482 (apply 'vc-do-command buffer okstatus "svn" file
483 (if (stringp vc-svn-global-switches)
484 (cons vc-svn-global-switches flags)
485 (append vc-svn-global-switches
486 flags))))
487
7ffc77d3
SM
488(defun vc-svn-repository-hostname (dirname)
489 (with-temp-buffer
490 (let ((coding-system-for-read
491 (or file-name-coding-system
492 default-file-name-coding-system)))
ace2fad9
CY
493 (vc-insert-file (expand-file-name (concat vc-svn-admin-directory
494 "/entries")
495 dirname)))
7ffc77d3
SM
496 (goto-char (point-min))
497 (when (re-search-forward
c45b3be3 498 ;; Old `svn' used name="svn:this_dir", newer use just name="".
17a5a301
SM
499 (concat "name=\"\\(?:svn:this_dir\\)?\"[\n\t ]*"
500 "\\(?:[-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
7ffc77d3 501 "url=\"\\([^\"]+\\)\"") nil t)
17a5a301
SM
502 ;; This is not a hostname but a URL. This may actually be considered
503 ;; as a feature since it allows vc-svn-stay-local to specify different
504 ;; behavior for different modules on the same server.
505 (match-string 1))))
1fd3454a 506
bc8c1bb4 507(defun vc-svn-parse-status (&optional filename)
1fd3454a 508 "Parse output of \"svn status\" command in the current buffer.
bc8c1bb4
SM
509Set file properties accordingly. Unless FILENAME is non-nil, parse only
510information about FILENAME and return its status."
1fd3454a
SM
511 (let (file status)
512 (goto-char (point-min))
513 (while (re-search-forward
c45b3be3
SM
514 ;; Ignore the files with status in [IX?].
515 "^[ ACDGMR!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t)
516 ;; If the username contains spaces, the output format is ambiguous,
517 ;; so don't trust the output's filename unless we have to.
518 (setq file (or filename
519 (expand-file-name
520 (buffer-substring (point) (line-end-position)))))
1fd3454a
SM
521 (setq status (char-after (line-beginning-position)))
522 (unless (eq status ??)
bc8c1bb4
SM
523 ;; `vc-BACKEND-registered' must not set vc-backend,
524 ;; which is instead set in vc-registered.
525 (unless filename (vc-file-setprop file 'vc-backend 'SVN))
fd140743
SM
526 ;; Use the last-modified revision, so that searching in vc-print-log
527 ;; output works.
528 (vc-file-setprop file 'vc-workfile-version (match-string 3))
1fd3454a
SM
529 (vc-file-setprop
530 file 'vc-state
531 (cond
532 ((eq status ?\ )
533 (if (eq (char-after (match-beginning 1)) ?*)
534 'needs-patch
535 (vc-file-setprop file 'vc-checkout-time
536 (nth 5 (file-attributes file)))
537 'up-to-date))
538 ((eq status ?A)
fd140743
SM
539 ;; If the file was actually copied, (match-string 2) is "-".
540 (vc-file-setprop file 'vc-workfile-version "0")
1fd3454a
SM
541 (vc-file-setprop file 'vc-checkout-time 0)
542 'edited)
543 ((memq status '(?M ?C))
544 (if (eq (char-after (match-beginning 1)) ?*)
545 'needs-merge
546 'edited))
bc8c1bb4
SM
547 (t 'edited)))))
548 (if filename (vc-file-getprop filename 'vc-state))))
1fd3454a
SM
549
550(defun vc-svn-dir-state-heuristic (dir)
551 "Find the SVN state of all files in DIR, using only local information."
552 (vc-svn-dir-state dir 'local))
553
554(defun vc-svn-valid-symbolic-tag-name-p (tag)
555 "Return non-nil if TAG is a valid symbolic tag name."
556 ;; According to the SVN manual, a valid symbolic tag must start with
557 ;; an uppercase or lowercase letter and can contain uppercase and
558 ;; lowercase letters, digits, `-', and `_'.
559 (and (string-match "^[a-zA-Z]" tag)
560 (not (string-match "[^a-z0-9A-Z-_]" tag))))
561
562(defun vc-svn-valid-version-number-p (tag)
563 "Return non-nil if TAG is a valid version number."
564 (and (string-match "^[0-9]" tag)
565 (not (string-match "[^0-9]" tag))))
566
17a5a301
SM
567;; Support for `svn annotate'
568
569(defun vc-svn-annotate-command (file buf &optional rev)
570 (vc-svn-command buf 0 file "annotate" (if rev (concat "-r" rev))))
571
572(defun vc-svn-annotate-time-of-rev (rev)
573 ;; Arbitrarily assume 10 commmits per day.
574 (/ (string-to-number rev) 10.0))
575
576(defun vc-svn-annotate-current-time ()
577 (vc-svn-annotate-time-of-rev vc-annotate-parent-rev))
578
579(defconst vc-svn-annotate-re "[ \t]*\\([0-9]+\\)[ \t]+[^\t ]+ ")
580
581(defun vc-svn-annotate-time ()
582 (when (looking-at vc-svn-annotate-re)
583 (goto-char (match-end 0))
584 (vc-svn-annotate-time-of-rev (match-string 1))))
585
586(defun vc-svn-annotate-extract-revision-at-line ()
587 (save-excursion
588 (beginning-of-line)
589 (if (looking-at vc-svn-annotate-re) (match-string 1))))
590
1fd3454a
SM
591(provide 'vc-svn)
592
f9d1f3be 593;; arch-tag: 02f10c68-2b4d-453a-90fc-1eee6cfb268d
1fd3454a 594;;; vc-svn.el ends here