(Fprin1_to_string): Instead of gcpro, set abort_on_gc.
[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
294(defun vc-svn-revert (file &optional contents-done)
295 "Revert FILE to the version it was based on."
296 (unless contents-done
297 (vc-svn-command nil 0 file "revert"))
298 (unless (eq (vc-checkout-model file) 'implicit)
299 (if vc-svn-use-edit
300 (vc-svn-command nil 0 file "unedit")
301 ;; Make the file read-only by switching off all w-bits
302 (set-file-modes file (logand (file-modes file) 3950)))))
303
304(defun vc-svn-merge (file first-version &optional second-version)
305 "Merge changes into current working copy of FILE.
306The changes are between FIRST-VERSION and SECOND-VERSION."
307 (vc-svn-command nil 0 file
c217cb04 308 "merge"
02610d0e 309 "-r" (if second-version
c217cb04
SM
310 (concat first-version ":" second-version)
311 first-version))
1fd3454a
SM
312 (vc-file-setprop file 'vc-state 'edited)
313 (with-current-buffer (get-buffer "*vc*")
314 (goto-char (point-min))
c217cb04
SM
315 (if (looking-at "C ")
316 1 ; signal conflict
1fd3454a
SM
317 0))) ; signal success
318
319(defun vc-svn-merge-news (file)
320 "Merge in any new changes made to FILE."
321 (message "Merging changes into %s..." file)
322 ;; (vc-file-setprop file 'vc-workfile-version nil)
323 (vc-file-setprop file 'vc-checkout-time 0)
324 (vc-svn-command nil 0 file "update")
325 ;; Analyze the merge result reported by SVN, and set
326 ;; file properties accordingly.
327 (with-current-buffer (get-buffer "*vc*")
328 (goto-char (point-min))
329 ;; get new workfile version
330 (if (re-search-forward
1468d754
SM
331 "^\\(Updated to\\|At\\) revision \\([0-9]+\\)" nil t)
332 (vc-file-setprop file 'vc-workfile-version (match-string 2))
1fd3454a
SM
333 (vc-file-setprop file 'vc-workfile-version nil))
334 ;; get file status
1468d754 335 (goto-char (point-min))
1fd3454a 336 (prog1
1468d754 337 (if (looking-at "At revision")
1fd3454a
SM
338 0 ;; there were no news; indicate success
339 (if (re-search-forward
1468d754
SM
340 (concat "^\\([CGDU] \\)?"
341 (regexp-quote (file-name-nondirectory file)))
1fd3454a
SM
342 nil t)
343 (cond
344 ;; Merge successful, we are in sync with repository now
1468d754 345 ((string= (match-string 1) "U ")
1fd3454a
SM
346 (vc-file-setprop file 'vc-state 'up-to-date)
347 (vc-file-setprop file 'vc-checkout-time
348 (nth 5 (file-attributes file)))
349 0);; indicate success to the caller
350 ;; Merge successful, but our own changes are still in the file
1468d754 351 ((string= (match-string 1) "G ")
1fd3454a
SM
352 (vc-file-setprop file 'vc-state 'edited)
353 0);; indicate success to the caller
354 ;; Conflicts detected!
355 (t
356 (vc-file-setprop file 'vc-state 'edited)
357 1);; signal the error to the caller
358 )
359 (pop-to-buffer "*vc*")
360 (error "Couldn't analyze svn update result")))
361 (message "Merging changes into %s...done" file))))
362
363
364;;;
365;;; History functions
366;;;
367
368(defun vc-svn-print-log (file)
369 "Get change log associated with FILE."
370 (save-current-buffer
371 (vc-setup-buffer nil)
372 (let ((inhibit-read-only t))
373 (goto-char (point-min))
374 ;; Add a line to tell log-view-mode what file this is.
375 (insert "Working file: " (file-relative-name file) "\n"))
376 (vc-svn-command
377 t
378 (if (and (vc-svn-stay-local-p file) (fboundp 'start-process)) 'async 0)
379 file "log")))
380
381(defun vc-svn-diff (file &optional oldvers newvers)
382 "Get a difference report using SVN between two versions of FILE."
fd140743
SM
383 (if (string= (vc-workfile-version file) "0")
384 ;; This file is added but not yet committed; there is no master file.
385 (if (or oldvers newvers)
386 (error "No revisions of %s exist" file)
387 ;; We regard this as "changed".
388 ;; Diff it against /dev/null.
389 ;; Note: this is NOT a "svn diff".
390 (apply 'vc-do-command "*vc-diff*"
391 1 "diff" file
392 (append (vc-switches nil 'diff) '("/dev/null")))
393 ;; Even if it's empty, it's locally modified.
394 1)
395 (let* ((switches (vc-switches 'SVN 'diff))
396 (async (and (vc-svn-stay-local-p file)
397 (or oldvers newvers) ; Svn diffs those locally.
398 (fboundp 'start-process)))
399 (status
400 (apply 'vc-svn-command "*vc-diff*"
401 (if async 'async 1)
402 file "diff"
1fd3454a 403 (append
fd140743
SM
404 (when switches
405 (list "-x" (mapconcat 'identity switches " ")))
1fd3454a 406 (when oldvers
fd140743
SM
407 (list "-r" (if newvers (concat oldvers ":" newvers)
408 oldvers)))))))
409 (if async 1 ; async diff => pessimistic assumption
410 ;; For some reason `svn diff' does not return a useful
411 ;; status w.r.t whether the diff was empty or not.
412 (buffer-size (get-buffer "*vc-diff*"))))))
1fd3454a
SM
413
414(defun vc-svn-diff-tree (dir &optional rev1 rev2)
415 "Diff all files at and below DIR."
416 (with-current-buffer "*vc-diff*"
417 (setq default-directory dir)
418 (if (vc-svn-stay-local-p dir)
419 ;; local diff: do it filewise, and only for files that are modified
420 (vc-file-tree-walk
421 dir
422 (lambda (f)
423 (vc-exec-after
424 `(let ((coding-system-for-read (vc-coding-system-for-diff ',f)))
425 ;; possible optimization: fetch the state of all files
426 ;; in the tree via vc-svn-dir-state-heuristic
427 (unless (vc-up-to-date-p ',f)
428 (message "Looking at %s" ',f)
429 (vc-diff-internal ',f ',rev1 ',rev2))))))
430 ;; svn diff: use a single call for the entire tree
431 (let ((coding-system-for-read (or coding-system-for-read 'undecided))
fd140743 432 (switches (vc-switches 'SVN 'diff)))
1fd3454a
SM
433 (apply 'vc-svn-command "*vc-diff*" 1 nil "diff"
434 (append
478e7df5 435 (when rev1
fd140743
SM
436 (list "-r" (if rev2 (concat rev1 ":" rev2) rev1)))
437 (when switches
438 (list "-x" (mapconcat 'identity switches " ")))))))))
1fd3454a
SM
439
440;;;
441;;; Snapshot system
442;;;
443
444(defun vc-svn-create-snapshot (dir name branchp)
445 "Assign to DIR's current version a given NAME.
446If BRANCHP is non-nil, the name is created as a branch (and the current
447workspace is immediately moved to that new branch)."
448 (vc-svn-command nil 0 dir "tag" "-c" (if branchp "-b") name)
449 (when branchp (vc-svn-command nil 0 dir "update" "-r" name)))
450
451(defun vc-svn-retrieve-snapshot (dir name update)
452 "Retrieve a snapshot at and below DIR.
453NAME is the name of the snapshot; if it is empty, do a `svn update'.
454If UPDATE is non-nil, then update (resynch) any affected buffers."
455 (with-current-buffer (get-buffer-create "*vc*")
456 (let ((default-directory dir)
457 (sticky-tag))
458 (erase-buffer)
459 (if (or (not name) (string= name ""))
460 (vc-svn-command t 0 nil "update")
461 (vc-svn-command t 0 nil "update" "-r" name)
462 (setq sticky-tag name))
463 (when update
464 (goto-char (point-min))
465 (while (not (eobp))
466 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
467 (let* ((file (expand-file-name (match-string 2) dir))
468 (state (match-string 1))
469 (buffer (find-buffer-visiting file)))
470 (when buffer
471 (cond
472 ((or (string= state "U")
473 (string= state "P"))
474 (vc-file-setprop file 'vc-state 'up-to-date)
475 (vc-file-setprop file 'vc-workfile-version nil)
476 (vc-file-setprop file 'vc-checkout-time
477 (nth 5 (file-attributes file))))
478 ((or (string= state "M")
479 (string= state "C"))
480 (vc-file-setprop file 'vc-state 'edited)
481 (vc-file-setprop file 'vc-workfile-version nil)
482 (vc-file-setprop file 'vc-checkout-time 0)))
483 (vc-file-setprop file 'vc-svn-sticky-tag sticky-tag)
484 (vc-resynch-buffer file t t))))
485 (forward-line 1))))))
486
487
488;;;
489;;; Miscellaneous
490;;;
491
492;; Subversion makes backups for us, so don't bother.
493;; (defalias 'vc-svn-make-version-backups-p 'vc-svn-stay-local-p
494;; "Return non-nil if version backups should be made for FILE.")
495
496(defun vc-svn-check-headers ()
497 "Check if the current file has any headers in it."
498 (save-excursion
499 (goto-char (point-min))
500 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\
501\\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t)))
502
503
504;;;
505;;; Internal functions
506;;;
507
508(defun vc-svn-command (buffer okstatus file &rest flags)
509 "A wrapper around `vc-do-command' for use in vc-svn.el.
510The difference to vc-do-command is that this function always invokes `svn',
511and that it passes `vc-svn-global-switches' to it before FLAGS."
512 (apply 'vc-do-command buffer okstatus "svn" file
513 (if (stringp vc-svn-global-switches)
514 (cons vc-svn-global-switches flags)
515 (append vc-svn-global-switches
516 flags))))
517
518(defun vc-svn-stay-local-p (file)
519 "Return non-nil if VC should stay local when handling FILE.
520See `vc-svn-stay-local'."
521 (when vc-svn-stay-local
522 (let* ((dirname (if (file-directory-p file)
523 (directory-file-name file)
524 (file-name-directory file)))
525 (prop
526 (or (vc-file-getprop dirname 'vc-svn-stay-local-p)
527 (vc-file-setprop
528 dirname 'vc-svn-stay-local-p
529 (let ((rootname (expand-file-name ".svn/entries" dirname)))
530 (cond
531 ((not (file-readable-p rootname)) 'no)
532 ((stringp vc-svn-stay-local)
533 (with-temp-buffer
534 (let ((coding-system-for-read
535 (or file-name-coding-system
536 default-file-name-coding-system)))
537 (vc-insert-file rootname))
538 (goto-char (point-min))
539 (when (re-search-forward
540 (concat "name=\"svn:this_dir\"[\n\t ]*"
541 "url=\"\\([^\"]+\\)\"") nil t)
542 (let ((hostname (match-string 1)))
543 (if (not hostname)
544 'no
545 (let* ((stay-local t)
546 (rx
547 (cond
548 ;; vc-svn-stay-local: rx
549 ((stringp vc-svn-stay-local)
550 vc-svn-stay-local)
551 ;; vc-svn-stay-local: '( [except] rx ... )
552 ((consp vc-svn-stay-local)
553 (mapconcat
554 'identity
555 (if (not (eq (car vc-svn-stay-local)
556 'except))
557 vc-svn-stay-local
558 (setq stay-local nil)
559 (cdr vc-svn-stay-local))
560 "\\|")))))
561 (if (not rx)
562 'yes
563 (if (not (string-match rx hostname))
564 (setq stay-local (not stay-local)))
565 (if stay-local
566 'yes
fd140743
SM
567 'no))))))))
568 ;; vc-svn-stay-local is neither nil nor list nor string.
569 (t 'yes)))))))
1fd3454a
SM
570 (if (eq prop 'yes) t nil))))
571
572(defun vc-svn-parse-status (localp)
573 "Parse output of \"svn status\" command in the current buffer.
574Set file properties accordingly. Unless FULL is t, parse only
575essential information."
576 (let (file status)
577 (goto-char (point-min))
578 (while (re-search-forward
fd140743 579 "^[ ADMCI?!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t)
1fd3454a
SM
580 (setq file (expand-file-name
581 (buffer-substring (point) (line-end-position))))
582 (setq status (char-after (line-beginning-position)))
583 (unless (eq status ??)
584 (vc-file-setprop file 'vc-backend 'SVN)
fd140743
SM
585 ;; Use the last-modified revision, so that searching in vc-print-log
586 ;; output works.
587 (vc-file-setprop file 'vc-workfile-version (match-string 3))
1fd3454a
SM
588 (vc-file-setprop
589 file 'vc-state
590 (cond
591 ((eq status ?\ )
592 (if (eq (char-after (match-beginning 1)) ?*)
593 'needs-patch
594 (vc-file-setprop file 'vc-checkout-time
595 (nth 5 (file-attributes file)))
596 'up-to-date))
597 ((eq status ?A)
fd140743
SM
598 ;; If the file was actually copied, (match-string 2) is "-".
599 (vc-file-setprop file 'vc-workfile-version "0")
1fd3454a
SM
600 (vc-file-setprop file 'vc-checkout-time 0)
601 'edited)
602 ((memq status '(?M ?C))
603 (if (eq (char-after (match-beginning 1)) ?*)
604 'needs-merge
605 'edited))
606 (t 'edited)))))))
607
608(defun vc-svn-dir-state-heuristic (dir)
609 "Find the SVN state of all files in DIR, using only local information."
610 (vc-svn-dir-state dir 'local))
611
612(defun vc-svn-valid-symbolic-tag-name-p (tag)
613 "Return non-nil if TAG is a valid symbolic tag name."
614 ;; According to the SVN manual, a valid symbolic tag must start with
615 ;; an uppercase or lowercase letter and can contain uppercase and
616 ;; lowercase letters, digits, `-', and `_'.
617 (and (string-match "^[a-zA-Z]" tag)
618 (not (string-match "[^a-z0-9A-Z-_]" tag))))
619
620(defun vc-svn-valid-version-number-p (tag)
621 "Return non-nil if TAG is a valid version number."
622 (and (string-match "^[0-9]" tag)
623 (not (string-match "[^0-9]" tag))))
624
625(provide 'vc-svn)
626
627;;; vc-svn.el ends here