diff lisp/vc-hg.el @ 87844:3bd7c8c8bbe7

* vc.el: Make vc-status asynchronous. (vc-update-vc-status-buffer): New function broken out of ... (vc-status-refresh): ... here. Pass vc-update-vc-status-buffer to the dir-status backend function. * vc-hg.el (vc-hg-dir-status): Compute the status asynchronously. Move the output processing to ... (vc-hg-after-dir-status): ... here. Call the function passed as an argument with the results.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 18 Jan 2008 23:32:58 +0000
parents beb524f8ba54
children 1a3c90d4d8fa
line wrap: on
line diff
--- a/lisp/vc-hg.el	Fri Jan 18 22:50:17 2008 +0000
+++ b/lisp/vc-hg.el	Fri Jan 18 23:32:58 2008 +0000
@@ -480,35 +480,41 @@
 
 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming")
 
-
 ;; XXX Experimental function for the vc-dired replacement.
-(defun vc-hg-dir-status (dir)
-  "Return a list of conses (file . state) for DIR."
-  (with-temp-buffer
-    (vc-hg-command (current-buffer) nil dir "status")
-    (goto-char (point-min))
-    (let ((status-char nil)
-	  (file nil)
-	  (translation '((?= . up-to-date)
-			 (?C . up-to-date)
-			 (?A . added)
-			 (?R . removed)
-			 (?M . edited)
-			 (?I . ignored)
-			 (?! . deleted)
-			 (?? . unregistered)))
-	  (translated nil)
+(defun vc-hg-after-dir-status (update-function buff)
+  (let ((status-char nil)
+	(file nil)
+	(translation '((?= . up-to-date)
+		       (?C . up-to-date)
+		       (?A . added)
+		       (?R . removed)
+		       (?M . edited)
+		       (?I . ignored)
+		       (?! . deleted)
+		       (?? . unregistered)))
+	(translated nil)
 	  (result nil))
+      (goto-char (point-min))
       (while (not (eobp))
 	(setq status-char (char-after))
 	(setq file 
 	      (buffer-substring-no-properties (+ (point) 2) 
-					       (line-end-position)))
+					      (line-end-position)))
 	(setq translated (assoc status-char translation))
 	(when (and translated (not (eq (cdr translated) 'up-to-date)))
 	  (push (cons file (cdr translated)) result))
 	(forward-line))
-      result)))
+      (funcall update-function result buff)))
+
+;; XXX Experimental function for the vc-dired replacement.
+(defun vc-hg-dir-status (dir update-function status-buffer)
+  "Return a list of conses (file . state) for DIR."
+  (with-current-buffer
+      (get-buffer-create
+       (expand-file-name " *VC-hg* tmp status" dir))
+    (vc-hg-command (current-buffer) 'async dir "status")
+    (vc-exec-after 
+     `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer))))
 
 ;; XXX this adds another top level menu, instead figure out how to
 ;; replace the Log-View menu.