New backend functions `delete-file' and `repository-hostname'.
[bpt/emacs.git] / lisp / vc-svn.el
CommitLineData
1fd3454a
SM
1;;; vc-svn.el --- non-resident support for Subversion version-control
2
3;; Copyright (C) 1995,98,99,2000,2001,2002 Free Software Foundation, Inc.
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
22;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23;; Boston, MA 02111-1307, USA.
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))
53 :version "21.4"
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))
65 :version "21.1"
66 :group 'vc)
67
68(defcustom vc-svn-diff-switches nil
69 "*A string or list of strings specifying extra switches for svn diff under VC."
70 :type '(choice (const :tag "None" nil)
71 (string :tag "Argument String")
72 (repeat :tag "Argument List"
73 :value ("")
74 string))
75 :version "21.1"
76 :group 'vc)
77
78(defcustom vc-svn-header (or (cdr (assoc 'SVN vc-header-alist)) '("\$Id\$"))
79 "*Header keywords to be inserted by `vc-insert-headers'."
80 :version "21.1"
81 :type '(repeat string)
82 :group 'vc)
83
84(defcustom vc-svn-use-edit nil
85 "*Non-nil means to use `svn edit' to \"check out\" a file.
86This is only meaningful if you don't use the implicit checkout model
87\(i.e. if you have $SVNREAD set)."
88 :type 'boolean
89 :version "21.1"
90 :group 'vc)
91
92(defcustom vc-svn-stay-local t
93 "*Non-nil means use local operations when possible for remote repositories.
94This avoids slow queries over the network and instead uses heuristics
95and past information to determine the current status of a file.
96
97The value can also be a regular expression or list of regular
98expressions to match against the host name of a repository; then VC
99only stays local for hosts that match it. Alternatively, the value
100can be a list of regular expressions where the first element is the
101symbol `except'; then VC always stays local except for hosts matched
102by these regular expressions."
103 :type '(choice (const :tag "Always stay local" t)
104 (const :tag "Don't stay local" nil)
105 (list :format "\nExamine hostname and %v" :tag "Examine hostname ..."
106 (set :format "%v" :inline t (const :format "%t" :tag "don't" except))
107 (regexp :format " stay local,\n%t: %v" :tag "if it matches")
108 (repeat :format "%v%i\n" :inline t (regexp :tag "or"))))
109 :version "21.1"
110 :group 'vc)
111
112;;;
113;;; State-querying functions
114;;;
115
116;;;###autoload (defun vc-svn-registered (f)
117;;;###autoload (when (file-readable-p (expand-file-name
118;;;###autoload ".svn/entries" (file-name-directory f)))
119;;;###autoload (load "vc-svn")
120;;;###autoload (vc-svn-registered f)))
121
122(defun vc-svn-registered (file)
123 "Check if FILE is SVN registered."
124 (when (file-readable-p (expand-file-name ".svn/entries"
125 (file-name-directory file)))
126 (with-temp-buffer
127 (cd (file-name-directory file))
128 (condition-case nil
129 (vc-svn-command t 0 file "status" "-v")
130 ;; We can't find an `svn' executable. We could also deregister SVN.
478e7df5 131 (file-error nil))
1fd3454a
SM
132 (vc-svn-parse-status t)
133 (eq 'SVN (vc-file-getprop file 'vc-backend)))))
134
135(defun vc-svn-state (file &optional localp)
136 "SVN-specific version of `vc-state'."
137 (setq localp (or localp (vc-svn-stay-local-p file)))
138 (with-temp-buffer
139 (cd (file-name-directory file))
140 (vc-svn-command t 0 file "status" (if localp "-v" "-u"))
141 (vc-svn-parse-status localp)
142 (vc-file-getprop file 'vc-state)))
143
144(defun vc-svn-state-heuristic (file)
145 "SVN-specific state heuristic."
146 (vc-svn-state file 'local))
147
148(defun vc-svn-dir-state (dir &optional localp)
149 "Find the SVN state of all files in DIR."
150 (setq localp (or localp (vc-svn-stay-local-p dir)))
151 (let ((default-directory dir))
152 ;; Don't specify DIR in this command, the default-directory is
153 ;; enough. Otherwise it might fail with remote repositories.
154 (with-temp-buffer
155 (vc-svn-command t 0 nil "status" (if localp "-v" "-u"))
156 (vc-svn-parse-status localp))))
157
158(defun vc-svn-workfile-version (file)
159 "SVN-specific version of `vc-workfile-version'."
160 ;; There is no need to consult RCS headers under SVN, because we
161 ;; get the workfile version for free when we recognize that a file
162 ;; is registered in SVN.
163 (vc-svn-registered file)
164 (vc-file-getprop file 'vc-workfile-version))
165
166(defun vc-svn-checkout-model (file)
167 "SVN-specific version of `vc-checkout-model'."
168 ;; It looks like Subversion has no equivalent of CVSREAD.
169 'implicit)
170
171(defun vc-svn-mode-line-string (file)
172 "Return string for placement into the modeline for FILE.
173Compared to the default implementation, this function does two things:
174Handle the special case of a SVN file that is added but not yet
175committed and support display of sticky tags."
176 (let* ((state (vc-state file))
177 (rev (vc-workfile-version file))
178 (sticky-tag (vc-file-getprop file 'vc-svn-sticky-tag))
179 (sticky-tag-printable (and sticky-tag
180 (not (string= sticky-tag ""))
181 (concat "[" sticky-tag "]"))))
182 (cond ((string= rev "0")
183 ;; A file that is added but not yet committed.
184 "SVN @@")
185 ((or (eq state 'up-to-date)
186 (eq state 'needs-patch))
187 (concat "SVN-" rev sticky-tag-printable))
188 ((stringp state)
189 (concat "SVN:" state ":" rev sticky-tag-printable))
190 (t
191 ;; Not just for the 'edited state, but also a fallback
192 ;; for all other states. Think about different symbols
193 ;; for 'needs-patch and 'needs-merge.
194 (concat "SVN:" rev sticky-tag-printable)))))
195
196(defun vc-svn-dired-state-info (file)
197 "SVN-specific version of `vc-dired-state-info'."
fd140743
SM
198 (let ((svn-state (vc-state file)))
199 (cond ((eq svn-state 'edited)
200 (if (equal (vc-workfile-version file) "0")
201 "(added)" "(modified)"))
202 ((eq svn-state 'needs-patch) "(patch)")
203 ((eq svn-state 'needs-merge) "(merge)"))))
1fd3454a
SM
204
205
206;;;
207;;; State-changing functions
208;;;
209
210(defun vc-svn-register (file &optional rev comment)
211 "Register FILE into the SVN version-control system.
212COMMENT can be used to provide an initial description of FILE.
213
214`vc-register-switches' and `vc-svn-register-switches' are passed to
215the SVN command (in that order)."
fd140743
SM
216 (apply 'vc-svn-command nil 0 file
217 "add"
218 ;; (and comment (string-match "[^\t\n ]" comment)
219 ;; (concat "-m" comment))
220 (vc-switches 'SVN 'register)))
1fd3454a
SM
221
222(defun vc-svn-responsible-p (file)
223 "Return non-nil if SVN thinks it is responsible for FILE."
224 (file-directory-p (expand-file-name ".svn"
225 (if (file-directory-p file)
226 file
227 (file-name-directory file)))))
228
229(defalias 'vc-svn-could-register 'vc-svn-responsible-p
230 "Return non-nil if FILE could be registered in SVN.
231This is only possible if SVN is responsible for FILE's directory.")
232
233(defun vc-svn-checkin (file rev comment)
234 "SVN-specific version of `vc-backend-checkin'."
fd140743
SM
235 (let ((status (apply 'vc-svn-command nil 1 file
236 "ci" (list* "-m" comment (vc-switches 'SVN 'checkin)))))
1fd3454a
SM
237 (set-buffer "*vc*")
238 (goto-char (point-min))
239 (unless (equal status 0)
240 ;; Check checkin problem.
241 (cond
fd140743 242 ((search-forward "Transaction is out of date" nil t)
1fd3454a
SM
243 (vc-file-setprop file 'vc-state 'needs-merge)
244 (error (substitute-command-keys
245 (concat "Up-to-date check failed: "
246 "type \\[vc-next-action] to merge in changes"))))
247 (t
248 (pop-to-buffer (current-buffer))
249 (goto-char (point-min))
250 (shrink-window-if-larger-than-buffer)
251 (error "Check-in failed"))))
252 ;; Update file properties
253 ;; (vc-file-setprop
254 ;; file 'vc-workfile-version
255 ;; (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
256 ))
257
258(defun vc-svn-find-version (file rev buffer)
259 (apply 'vc-svn-command
260 buffer 0 file
261 "cat"
262 (and rev (not (string= rev ""))
263 (concat "-r" rev))
fd140743 264 (vc-switches 'SVN 'checkout)))
1fd3454a
SM
265
266(defun vc-svn-checkout (file &optional editable rev)
267 (message "Checking out %s..." file)
268 (with-current-buffer (or (get-file-buffer file) (current-buffer))
fd140743 269 (vc-call update file editable rev (vc-switches 'SVN 'checkout)))
1fd3454a
SM
270 (vc-mode-line file)
271 (message "Checking out %s...done" file))
272
273(defun vc-svn-update (file editable rev switches)
274 (if (and (file-exists-p file) (not rev))
275 ;; If no revision was specified, just make the file writable
276 ;; if necessary (using `svn-edit' if requested).
277 (and editable (not (eq (vc-svn-checkout-model file) 'implicit))
278 (if vc-svn-use-edit
279 (vc-svn-command nil 0 file "edit")
280 (set-file-modes file (logior (file-modes file) 128))
281 (if (equal file buffer-file-name) (toggle-read-only -1))))
282 ;; Check out a particular version (or recreate the file).
283 (vc-file-setprop file 'vc-workfile-version nil)
284 (apply 'vc-svn-command nil 0 file
285 "-w"
286 "update"
287 ;; default for verbose checkout: clear the sticky tag so
288 ;; that the actual update will get the head of the trunk
289 (if (or (not rev) (string= rev ""))
290 "-A"
291 (concat "-r" rev))
292 switches)))
293
2766aaaf
SM
294(defun vc-svn-rename-file (old new)
295 (vc-svn-command nil 0 new "move" (file-relative-name old)))
296
1fd3454a
SM
297(defun vc-svn-revert (file &optional contents-done)
298 "Revert FILE to the version it was based on."
299 (unless contents-done
300 (vc-svn-command nil 0 file "revert"))
301 (unless (eq (vc-checkout-model file) 'implicit)
302 (if vc-svn-use-edit
303 (vc-svn-command nil 0 file "unedit")
304 ;; Make the file read-only by switching off all w-bits
305 (set-file-modes file (logand (file-modes file) 3950)))))
306
307(defun vc-svn-merge (file first-version &optional second-version)
308 "Merge changes into current working copy of FILE.
309The changes are between FIRST-VERSION and SECOND-VERSION."
310 (vc-svn-command nil 0 file
c217cb04 311 "merge"
02610d0e 312 "-r" (if second-version
c217cb04
SM
313 (concat first-version ":" second-version)
314 first-version))
1fd3454a
SM
315 (vc-file-setprop file 'vc-state 'edited)
316 (with-current-buffer (get-buffer "*vc*")
317 (goto-char (point-min))
c217cb04
SM
318 (if (looking-at "C ")
319 1 ; signal conflict
1fd3454a
SM
320 0))) ; signal success
321
322(defun vc-svn-merge-news (file)
323 "Merge in any new changes made to FILE."
324 (message "Merging changes into %s..." file)
325 ;; (vc-file-setprop file 'vc-workfile-version nil)
326 (vc-file-setprop file 'vc-checkout-time 0)
327 (vc-svn-command nil 0 file "update")
328 ;; Analyze the merge result reported by SVN, and set
329 ;; file properties accordingly.
330 (with-current-buffer (get-buffer "*vc*")
331 (goto-char (point-min))
332 ;; get new workfile version
333 (if (re-search-forward
1468d754
SM
334 "^\\(Updated to\\|At\\) revision \\([0-9]+\\)" nil t)
335 (vc-file-setprop file 'vc-workfile-version (match-string 2))
1fd3454a
SM
336 (vc-file-setprop file 'vc-workfile-version nil))
337 ;; get file status
1468d754 338 (goto-char (point-min))
1fd3454a 339 (prog1
1468d754 340 (if (looking-at "At revision")
1fd3454a
SM
341 0 ;; there were no news; indicate success
342 (if (re-search-forward
1468d754
SM
343 (concat "^\\([CGDU] \\)?"
344 (regexp-quote (file-name-nondirectory file)))
1fd3454a
SM
345 nil t)
346 (cond
347 ;; Merge successful, we are in sync with repository now
1468d754 348 ((string= (match-string 1) "U ")
1fd3454a
SM
349 (vc-file-setprop file 'vc-state 'up-to-date)
350 (vc-file-setprop file 'vc-checkout-time
351 (nth 5 (file-attributes file)))
352 0);; indicate success to the caller
353 ;; Merge successful, but our own changes are still in the file
1468d754 354 ((string= (match-string 1) "G ")
1fd3454a
SM
355 (vc-file-setprop file 'vc-state 'edited)
356 0);; indicate success to the caller
357 ;; Conflicts detected!
358 (t
359 (vc-file-setprop file 'vc-state 'edited)
360 1);; signal the error to the caller
361 )
362 (pop-to-buffer "*vc*")
363 (error "Couldn't analyze svn update result")))
364 (message "Merging changes into %s...done" file))))
365
366
367;;;
368;;; History functions
369;;;
370
371(defun vc-svn-print-log (file)
372 "Get change log associated with FILE."
373 (save-current-buffer
374 (vc-setup-buffer nil)
375 (let ((inhibit-read-only t))
376 (goto-char (point-min))
377 ;; Add a line to tell log-view-mode what file this is.
378 (insert "Working file: " (file-relative-name file) "\n"))
379 (vc-svn-command
380 t
381 (if (and (vc-svn-stay-local-p file) (fboundp 'start-process)) 'async 0)
382 file "log")))
383
384(defun vc-svn-diff (file &optional oldvers newvers)
385 "Get a difference report using SVN between two versions of FILE."
fd140743
SM
386 (if (string= (vc-workfile-version file) "0")
387 ;; This file is added but not yet committed; there is no master file.
388 (if (or oldvers newvers)
389 (error "No revisions of %s exist" file)
390 ;; We regard this as "changed".
391 ;; Diff it against /dev/null.
392 ;; Note: this is NOT a "svn diff".
393 (apply 'vc-do-command "*vc-diff*"
394 1 "diff" file
395 (append (vc-switches nil 'diff) '("/dev/null")))
396 ;; Even if it's empty, it's locally modified.
397 1)
398 (let* ((switches (vc-switches 'SVN 'diff))
399 (async (and (vc-svn-stay-local-p file)
400 (or oldvers newvers) ; Svn diffs those locally.
2766aaaf
SM
401 (fboundp 'start-process))))
402 (apply 'vc-svn-command "*vc-diff*"
403 (if async 'async 0)
404 file "diff"
405 (append
406 (when switches
407 (list "-x" (mapconcat 'identity switches " ")))
408 (when oldvers
409 (list "-r" (if newvers (concat oldvers ":" newvers)
410 oldvers)))))
fd140743
SM
411 (if async 1 ; async diff => pessimistic assumption
412 ;; For some reason `svn diff' does not return a useful
413 ;; status w.r.t whether the diff was empty or not.
414 (buffer-size (get-buffer "*vc-diff*"))))))
1fd3454a
SM
415
416(defun vc-svn-diff-tree (dir &optional rev1 rev2)
417 "Diff all files at and below DIR."
418 (with-current-buffer "*vc-diff*"
419 (setq default-directory dir)
420 (if (vc-svn-stay-local-p dir)
421 ;; local diff: do it filewise, and only for files that are modified
422 (vc-file-tree-walk
423 dir
424 (lambda (f)
425 (vc-exec-after
426 `(let ((coding-system-for-read (vc-coding-system-for-diff ',f)))
427 ;; possible optimization: fetch the state of all files
428 ;; in the tree via vc-svn-dir-state-heuristic
429 (unless (vc-up-to-date-p ',f)
430 (message "Looking at %s" ',f)
431 (vc-diff-internal ',f ',rev1 ',rev2))))))
432 ;; svn diff: use a single call for the entire tree
433 (let ((coding-system-for-read (or coding-system-for-read 'undecided))
fd140743 434 (switches (vc-switches 'SVN 'diff)))
1fd3454a
SM
435 (apply 'vc-svn-command "*vc-diff*" 1 nil "diff"
436 (append
478e7df5 437 (when rev1
fd140743
SM
438 (list "-r" (if rev2 (concat rev1 ":" rev2) rev1)))
439 (when switches
440 (list "-x" (mapconcat 'identity switches " ")))))))))
1fd3454a
SM
441
442;;;
443;;; Snapshot system
444;;;
445
446(defun vc-svn-create-snapshot (dir name branchp)
447 "Assign to DIR's current version a given NAME.
448If BRANCHP is non-nil, the name is created as a branch (and the current
449workspace is immediately moved to that new branch)."
450 (vc-svn-command nil 0 dir "tag" "-c" (if branchp "-b") name)
451 (when branchp (vc-svn-command nil 0 dir "update" "-r" name)))
452
453(defun vc-svn-retrieve-snapshot (dir name update)
454 "Retrieve a snapshot at and below DIR.
455NAME is the name of the snapshot; if it is empty, do a `svn update'.
456If UPDATE is non-nil, then update (resynch) any affected buffers."
457 (with-current-buffer (get-buffer-create "*vc*")
458 (let ((default-directory dir)
459 (sticky-tag))
460 (erase-buffer)
461 (if (or (not name) (string= name ""))
462 (vc-svn-command t 0 nil "update")
463 (vc-svn-command t 0 nil "update" "-r" name)
464 (setq sticky-tag name))
465 (when update
466 (goto-char (point-min))
467 (while (not (eobp))
468 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
469 (let* ((file (expand-file-name (match-string 2) dir))
470 (state (match-string 1))
471 (buffer (find-buffer-visiting file)))
472 (when buffer
473 (cond
474 ((or (string= state "U")
475 (string= state "P"))
476 (vc-file-setprop file 'vc-state 'up-to-date)
477 (vc-file-setprop file 'vc-workfile-version nil)
478 (vc-file-setprop file 'vc-checkout-time
479 (nth 5 (file-attributes file))))
480 ((or (string= state "M")
481 (string= state "C"))
482 (vc-file-setprop file 'vc-state 'edited)
483 (vc-file-setprop file 'vc-workfile-version nil)
484 (vc-file-setprop file 'vc-checkout-time 0)))
485 (vc-file-setprop file 'vc-svn-sticky-tag sticky-tag)
486 (vc-resynch-buffer file t t))))
487 (forward-line 1))))))
488
489
490;;;
491;;; Miscellaneous
492;;;
493
494;; Subversion makes backups for us, so don't bother.
495;; (defalias 'vc-svn-make-version-backups-p 'vc-svn-stay-local-p
496;; "Return non-nil if version backups should be made for FILE.")
497
498(defun vc-svn-check-headers ()
499 "Check if the current file has any headers in it."
500 (save-excursion
501 (goto-char (point-min))
502 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
503\\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
504
505
506;;;
507;;; Internal functions
508;;;
509
510(defun vc-svn-command (buffer okstatus file &rest flags)
511 "A wrapper around `vc-do-command' for use in vc-svn.el.
512The difference to vc-do-command is that this function always invokes `svn',
513and that it passes `vc-svn-global-switches' to it before FLAGS."
514 (apply 'vc-do-command buffer okstatus "svn" file
515 (if (stringp vc-svn-global-switches)
516 (cons vc-svn-global-switches flags)
517 (append vc-svn-global-switches
518 flags))))
519
520(defun vc-svn-stay-local-p (file)
521 "Return non-nil if VC should stay local when handling FILE.
522See `vc-svn-stay-local'."
523 (when vc-svn-stay-local
524 (let* ((dirname (if (file-directory-p file)
525 (directory-file-name file)
526 (file-name-directory file)))
527 (prop
528 (or (vc-file-getprop dirname 'vc-svn-stay-local-p)
529 (vc-file-setprop
530 dirname 'vc-svn-stay-local-p
531 (let ((rootname (expand-file-name ".svn/entries" dirname)))
532 (cond
533 ((not (file-readable-p rootname)) 'no)
534 ((stringp vc-svn-stay-local)
535 (with-temp-buffer
536 (let ((coding-system-for-read
537 (or file-name-coding-system
538 default-file-name-coding-system)))
539 (vc-insert-file rootname))
540 (goto-char (point-min))
541 (when (re-search-forward
542 (concat "name=\"svn:this_dir\"[\n\t ]*"
543 "url=\"\\([^\"]+\\)\"") nil t)
544 (let ((hostname (match-string 1)))
545 (if (not hostname)
546 'no
547 (let* ((stay-local t)
548 (rx
549 (cond
550 ;; vc-svn-stay-local: rx
551 ((stringp vc-svn-stay-local)
552 vc-svn-stay-local)
553 ;; vc-svn-stay-local: '( [except] rx ... )
554 ((consp vc-svn-stay-local)
555 (mapconcat
556 'identity
557 (if (not (eq (car vc-svn-stay-local)
558 'except))
559 vc-svn-stay-local
560 (setq stay-local nil)
561 (cdr vc-svn-stay-local))
562 "\\|")))))
563 (if (not rx)
564 'yes
565 (if (not (string-match rx hostname))
566 (setq stay-local (not stay-local)))
567 (if stay-local
568 'yes
fd140743
SM
569 'no))))))))
570 ;; vc-svn-stay-local is neither nil nor list nor string.
571 (t 'yes)))))))
1fd3454a
SM
572 (if (eq prop 'yes) t nil))))
573
574(defun vc-svn-parse-status (localp)
575 "Parse output of \"svn status\" command in the current buffer.
576Set file properties accordingly. Unless FULL is t, parse only
577essential information."
578 (let (file status)
579 (goto-char (point-min))
580 (while (re-search-forward
fd140743 581 "^[ ADMCI?!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t)
1fd3454a
SM
582 (setq file (expand-file-name
583 (buffer-substring (point) (line-end-position))))
584 (setq status (char-after (line-beginning-position)))
585 (unless (eq status ??)
586 (vc-file-setprop file 'vc-backend 'SVN)
fd140743
SM
587 ;; Use the last-modified revision, so that searching in vc-print-log
588 ;; output works.
589 (vc-file-setprop file 'vc-workfile-version (match-string 3))
1fd3454a
SM
590 (vc-file-setprop
591 file 'vc-state
592 (cond
593 ((eq status ?\ )
594 (if (eq (char-after (match-beginning 1)) ?*)
595 'needs-patch
596 (vc-file-setprop file 'vc-checkout-time
597 (nth 5 (file-attributes file)))
598 'up-to-date))
599 ((eq status ?A)
fd140743
SM
600 ;; If the file was actually copied, (match-string 2) is "-".
601 (vc-file-setprop file 'vc-workfile-version "0")
1fd3454a
SM
602 (vc-file-setprop file 'vc-checkout-time 0)
603 'edited)
604 ((memq status '(?M ?C))
605 (if (eq (char-after (match-beginning 1)) ?*)
606 'needs-merge
607 'edited))
608 (t 'edited)))))))
609
610(defun vc-svn-dir-state-heuristic (dir)
611 "Find the SVN state of all files in DIR, using only local information."
612 (vc-svn-dir-state dir 'local))
613
614(defun vc-svn-valid-symbolic-tag-name-p (tag)
615 "Return non-nil if TAG is a valid symbolic tag name."
616 ;; According to the SVN manual, a valid symbolic tag must start with
617 ;; an uppercase or lowercase letter and can contain uppercase and
618 ;; lowercase letters, digits, `-', and `_'.
619 (and (string-match "^[a-zA-Z]" tag)
620 (not (string-match "[^a-z0-9A-Z-_]" tag))))
621
622(defun vc-svn-valid-version-number-p (tag)
623 "Return non-nil if TAG is a valid version number."
624 (and (string-match "^[0-9]" tag)
625 (not (string-match "[^0-9]" tag))))
626
627(provide 'vc-svn)
628
629;;; vc-svn.el ends here