changeset 94094:9ec1b62752b1

(vc-cvs-after-dir-status, vc-cvs-dir-status): Add alternative implementation based on "cvs update".
author Dan Nicolaescu <dann@ics.uci.edu>
date Tue, 15 Apr 2008 07:26:36 +0000
parents c040fae879e0
children e8b7cae31fe3
files lisp/ChangeLog lisp/vc-cvs.el
diffstat 2 files changed, 79 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Apr 15 06:46:11 2008 +0000
+++ b/lisp/ChangeLog	Tue Apr 15 07:26:36 2008 +0000
@@ -1,3 +1,8 @@
+2008-04-15  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc-cvs.el (vc-cvs-after-dir-status, vc-cvs-dir-status): Add
+	alternative implementation based on "cvs update".
+
 2008-04-15  Tassilo Horn  <tassilo@member.fsf.org>
 
 	* doc-view.el: Changed requirements section to tell that only one
--- a/lisp/vc-cvs.el	Tue Apr 15 06:46:11 2008 +0000
+++ b/lisp/vc-cvs.el	Tue Apr 15 07:26:36 2008 +0000
@@ -908,15 +908,88 @@
 	      (push (list file status) result))))))
       (goto-char (point-max))
       (widen))
-      (funcall update-function result)))
+      (funcall update-function result))
+  ;; Alternative implementation: use the "update" command instead of
+  ;; the "status" command.
+  ;; (let ((result nil)
+  ;; 	(translation '((?? . unregistered)
+  ;; 		       (?A . added)
+  ;; 		       (?C . conflict)
+  ;; 		       (?M . edited)
+  ;; 		       (?P . needs-merge)
+  ;; 		       (?R . removed)
+  ;; 		       (?U . needs-patch))))
+  ;;   (goto-char (point-min))
+  ;;   (while (not (eobp))
+  ;;     (if (looking-at "^[ACMPRU?] \\(.*\\)$")
+  ;; 	  (push (list (match-string 1) 
+  ;; 		      (cdr (assoc (char-after) translation))) 
+  ;; 		result)
+  ;; 	(cond
+  ;; 	 ((looking-at "cvs update: warning: \\(.*\\) was lost")
+  ;; 	  ;; Format is:
+  ;; 	  ;; cvs update: warning: FILENAME was lost
+  ;; 	  ;; U FILENAME
+  ;; 	  (push (list (match-string 1) 'missing) result)
+  ;; 	  ;; Skip the "U" line
+  ;; 	  (forward-line 1))
+  ;; 	 ((looking-at "cvs update: New directory `\\(.*\\)' -- ignored")
+  ;; 	  (push (list (match-string 1) 'unregistered) result))))
+  ;;     (forward-line 1))
+  ;;   (funcall update-function result)))
+  )
 
 ;; XXX Experimental function for the vc-dired replacement.
 (defun vc-cvs-dir-status (dir update-function)
   "Create a list of conses (file . state) for DIR."
   (vc-cvs-command (current-buffer) 'async dir "status")
+  ;; Alternative implementation: use the "update" command instead of
+  ;; the "status" command.
+  ;; (vc-cvs-command (current-buffer) 'async
+  ;; 		  (file-relative-name dir)
+  ;; 		  "-f" "-n" "update" "-d" "-P")
   (vc-exec-after
    `(vc-cvs-after-dir-status (quote ,update-function))))
 
+(defun vc-cvs-after-dir-status (update-function)
+  ;; Heavily inspired by vc-cvs-parse-status. AKA a quick hack.
+  ;; It needs a lot of testing.
+  (let ((result nil)
+	(translation '((?? . unregistered)
+		       (?A . added)
+		       (?C . conflict)
+		       (?M . edited)
+		       (?P . needs-merge)
+		       (?R . removed)
+		       (?U . needs-patch))))
+    (goto-char (point-min))
+    (while (not (eobp))
+      (if (looking-at "^[ACMPRU?] \\(.*\\)$")
+	  (push (list (match-string 1) 
+		      (cdr (assoc (char-after) translation))) 
+		result)
+	(cond
+	 ((looking-at "cvs update: warning: \\(.*\\) was lost")
+	  ;; Format is:
+	  ;; cvs update: warning: FILENAME was lost
+	  ;; U FILENAME
+	  (push (list (match-string 1) 'missing) result)
+	  ;; Skip the "U" line
+	  (forward-line 1))
+	 ((looking-at "cvs update: New directory `\\(.*\\)' -- ignored")
+	  (push (list (match-string 1) 'unregistered) result))))
+      (forward-line 1))
+    (funcall update-function result)))
+
+(defun vc-cvs-dir-status (dir update-function)
+  "Create a list of conses (file . state) for DIR."
+  (vc-cvs-command (current-buffer) 'async
+		  (file-relative-name dir)
+		  "-f" "-n" "update" "-d" "-P")
+  (vc-exec-after
+   `(vc-cvs-after-dir-status (quote ,update-function))))
+
+
 (defun vc-cvs-get-entries (dir)
   "Insert the CVS/Entries file from below DIR into the current buffer.
 This function ensures that the correct coding system is used for that,