]> code.delx.au - gnu-emacs/blobdiff - lisp/vc-svn.el
(math-random-digit): Call math-init-random-base if var-RandSeed is nil.
[gnu-emacs] / lisp / vc-svn.el
index 1d46c90d9c86942188dbbf7e517b83e8e00b2c04..cbb951d60b7b35b14aa7aad7faecb23ad84256f5 100644 (file)
@@ -1,6 +1,7 @@
 ;;; vc-svn.el --- non-resident support for Subversion version-control
 
-;; Copyright (C) 1995,98,99,2000,2001,02,2003  Free Software Foundation, Inc.
+;; Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+;;           Free Software Foundation, Inc.
 
 ;; Author:      FSF (see vc.el for full credits)
 ;; Maintainer:  Stefan Monnier <monnier@gnu.org>
@@ -195,8 +196,9 @@ This is only possible if SVN is responsible for FILE's directory.")
 
 (defun vc-svn-checkin (file rev comment)
   "SVN-specific version of `vc-backend-checkin'."
-  (let ((status (apply 'vc-svn-command nil 1 file
-                      "ci" (list* "-m" comment (vc-switches 'SVN 'checkin)))))
+  (let ((status (apply
+                 'vc-svn-command nil 1 file "ci"
+                 (nconc (list "-m" comment) (vc-switches 'SVN 'checkin)))))
     (set-buffer "*vc*")
     (goto-char (point-min))
     (unless (equal status 0)
@@ -334,21 +336,22 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
 ;;; History functions
 ;;;
 
-(defun vc-svn-print-log (file)
+(defun vc-svn-print-log (file &optional buffer)
   "Get change log associated with FILE."
   (save-current-buffer
-    (vc-setup-buffer nil)
+    (vc-setup-buffer buffer)
     (let ((inhibit-read-only t))
       (goto-char (point-min))
       ;; Add a line to tell log-view-mode what file this is.
       (insert "Working file: " (file-relative-name file) "\n"))
     (vc-svn-command
-     t
+     buffer
      (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
      file "log")))
 
-(defun vc-svn-diff (file &optional oldvers newvers)
+(defun vc-svn-diff (file &optional oldvers newvers buffer)
   "Get a difference report using SVN between two versions of FILE."
+  (unless buffer (setq buffer "*vc-diff*"))
   (if (string= (vc-workfile-version file) "0")
       ;; This file is added but not yet committed; there is no master file.
       (if (or oldvers newvers)
@@ -356,28 +359,30 @@ The changes are between FIRST-VERSION and SECOND-VERSION."
        ;; We regard this as "changed".
        ;; Diff it against /dev/null.
        ;; Note: this is NOT a "svn diff".
-       (apply 'vc-do-command "*vc-diff*"
+       (apply 'vc-do-command buffer
               1 "diff" file
               (append (vc-switches nil 'diff) '("/dev/null")))
        ;; Even if it's empty, it's locally modified.
        1)
-    (let* ((switches (vc-switches 'SVN 'diff))
+    (let* ((switches
+           (if vc-svn-diff-switches
+               (vc-switches 'SVN 'diff)
+             (list "-x" (mapconcat 'identity (vc-switches nil 'diff) " "))))
           (async (and (vc-stay-local-p file)
                       (or oldvers newvers) ; Svn diffs those locally.
                       (fboundp 'start-process))))
-      (apply 'vc-svn-command "*vc-diff*"
+      (apply 'vc-svn-command buffer
             (if async 'async 0)
             file "diff"
             (append
-             (when switches
-               (list "-x" (mapconcat 'identity switches " ")))
+             switches
              (when oldvers
                (list "-r" (if newvers (concat oldvers ":" newvers)
                             oldvers)))))
       (if async 1                    ; async diff => pessimistic assumption
        ;; For some reason `svn diff' does not return a useful
        ;; status w.r.t whether the diff was empty or not.
-       (buffer-size (get-buffer "*vc-diff*"))))))
+       (buffer-size (get-buffer buffer))))))
 
 (defun vc-svn-diff-tree (dir &optional rev1 rev2)
   "Diff all files at and below DIR."
@@ -442,10 +447,14 @@ and that it passes `vc-svn-global-switches' to it before FLAGS."
       (vc-insert-file (expand-file-name ".svn/entries" dirname)))
     (goto-char (point-min))
     (when (re-search-forward
-          (concat "name=\"svn:this_dir\"[\n\t ]*"
-                  "\\([-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
+          ;; Old `svn' used name="svn:dir", newer use just name="".
+          (concat "name=\"\\(?:svn:this_dir\\)?\"[\n\t ]*"
+                  "\\(?:[-a-z]+=\"[^\"]*\"[\n\t ]*\\)*?"
                   "url=\"\\([^\"]+\\)\"") nil t)
-      (match-string 2))))
+      ;; This is not a hostname but a URL.  This may actually be considered
+      ;; as a feature since it allows vc-svn-stay-local to specify different
+      ;; behavior for different modules on the same server.
+      (match-string 1))))
 
 (defun vc-svn-parse-status (localp)
   "Parse output of \"svn status\" command in the current buffer.
@@ -500,6 +509,31 @@ essential information."
   (and (string-match "^[0-9]" tag)
        (not (string-match "[^0-9]" tag))))
 
+;; Support for `svn annotate'
+
+(defun vc-svn-annotate-command (file buf &optional rev)
+  (vc-svn-command buf 0 file "annotate" (if rev (concat "-r" rev))))
+
+(defun vc-svn-annotate-time-of-rev (rev)
+  ;; Arbitrarily assume 10 commmits per day.
+  (/ (string-to-number rev) 10.0))
+
+(defun vc-svn-annotate-current-time ()
+  (vc-svn-annotate-time-of-rev vc-annotate-parent-rev))
+
+(defconst vc-svn-annotate-re "[ \t]*\\([0-9]+\\)[ \t]+[^\t ]+ ")
+
+(defun vc-svn-annotate-time ()
+  (when (looking-at vc-svn-annotate-re)
+    (goto-char (match-end 0))
+    (vc-svn-annotate-time-of-rev (match-string 1))))
+
+(defun vc-svn-annotate-extract-revision-at-line ()
+  (save-excursion
+    (beginning-of-line)
+    (if (looking-at vc-svn-annotate-re) (match-string 1))))
+
 (provide 'vc-svn)
 
+;; arch-tag: 02f10c68-2b4d-453a-90fc-1eee6cfb268d
 ;;; vc-svn.el ends here