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