]> git.eshelyaron.com Git - emacs.git/commitdiff
* vc.el: Make vc-status asynchronous.
authorDan Nicolaescu <dann@ics.uci.edu>
Fri, 18 Jan 2008 23:32:58 +0000 (23:32 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Fri, 18 Jan 2008 23:32:58 +0000 (23:32 +0000)
(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.

lisp/ChangeLog
lisp/vc-hg.el
lisp/vc.el

index 182812f2c7a3b05294d3f8408f1af263819d37bc..a629893a38d66c118e78dd5206f74731bfb19e53 100644 (file)
@@ -1,3 +1,15 @@
+2008-01-18  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       * 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.
+
 2008-01-18  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * doc-view.el (doc-view-pdf/ps->png): Make sure we a have a valid cwd.
index fe441d984f7a5235b862920a13be866421dfca08..c3c3b5577f3ec39bd5a83d772ca5933bd326b751 100644 (file)
@@ -480,35 +480,41 @@ REV is the revision to check out into WORKFILE."
 
 (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.
index bb05625f577f51a706b33b4db3f7920ba6963c61..a0f8ce1702c90ee1c6131abe0ebd10420dc285f6 100644 (file)
 ;;
 ;; - decide if vc-status should replace vc-dired.
 ;;
-;; - vc-status should be made asynchronous.
-;;
 ;; - vc-status needs a menu, mouse bindings and some color bling.
 
 ;;; Code:
@@ -2622,16 +2620,26 @@ With prefix arg READ-SWITCHES, specify a value to override
 
 (put 'vc-status-mode 'mode-class 'special)
 
+(defun vc-update-vc-status-buffer (entries buffer)
+  (with-current-buffer buffer
+    (dolist (entry entries)
+      (ewoc-enter-last vc-status
+                      (vc-status-create-fileinfo (cdr entry) (car entry))))
+    (ewoc-goto-node vc-status (ewoc-nth vc-status 0))))
+
 (defun vc-status-refresh ()
   "Refresh the contents of the VC status buffer."
   (interactive)
   ;; This is not very efficient; ewoc could use a new function here.
   (ewoc-filter vc-status (lambda (node) nil))
   (let ((backend (vc-responsible-backend default-directory)))
-    (dolist (entry (vc-call-backend backend 'dir-status default-directory))
-      (ewoc-enter-last vc-status
-                      (vc-status-create-fileinfo (cdr entry) (car entry)))))
-  (ewoc-goto-node vc-status (ewoc-nth vc-status 0)))
+    ;; Call the dir-status backend function. dir-status is supposed to
+    ;; be asynchronous.  It should compute the results and call the
+    ;; function passed as a an arg to update the vc-status buffer with
+    ;; the results.
+    (vc-call-backend 
+     backend 'dir-status default-directory 
+     #'vc-update-vc-status-buffer (current-buffer))))
 
 (defun vc-status-next-line (arg)
   "Go to the next line.