comparison 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
comparison
equal deleted inserted replaced
87843:e1d6c4e34d2c 87844:3bd7c8c8bbe7
478 478
479 (define-derived-mode vc-hg-outgoing-mode vc-hg-log-view-mode "Hg-Outgoing") 479 (define-derived-mode vc-hg-outgoing-mode vc-hg-log-view-mode "Hg-Outgoing")
480 480
481 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") 481 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming")
482 482
483
484 ;; XXX Experimental function for the vc-dired replacement. 483 ;; XXX Experimental function for the vc-dired replacement.
485 (defun vc-hg-dir-status (dir) 484 (defun vc-hg-after-dir-status (update-function buff)
486 "Return a list of conses (file . state) for DIR." 485 (let ((status-char nil)
487 (with-temp-buffer 486 (file nil)
488 (vc-hg-command (current-buffer) nil dir "status") 487 (translation '((?= . up-to-date)
489 (goto-char (point-min)) 488 (?C . up-to-date)
490 (let ((status-char nil) 489 (?A . added)
491 (file nil) 490 (?R . removed)
492 (translation '((?= . up-to-date) 491 (?M . edited)
493 (?C . up-to-date) 492 (?I . ignored)
494 (?A . added) 493 (?! . deleted)
495 (?R . removed) 494 (?? . unregistered)))
496 (?M . edited) 495 (translated nil)
497 (?I . ignored)
498 (?! . deleted)
499 (?? . unregistered)))
500 (translated nil)
501 (result nil)) 496 (result nil))
497 (goto-char (point-min))
502 (while (not (eobp)) 498 (while (not (eobp))
503 (setq status-char (char-after)) 499 (setq status-char (char-after))
504 (setq file 500 (setq file
505 (buffer-substring-no-properties (+ (point) 2) 501 (buffer-substring-no-properties (+ (point) 2)
506 (line-end-position))) 502 (line-end-position)))
507 (setq translated (assoc status-char translation)) 503 (setq translated (assoc status-char translation))
508 (when (and translated (not (eq (cdr translated) 'up-to-date))) 504 (when (and translated (not (eq (cdr translated) 'up-to-date)))
509 (push (cons file (cdr translated)) result)) 505 (push (cons file (cdr translated)) result))
510 (forward-line)) 506 (forward-line))
511 result))) 507 (funcall update-function result buff)))
508
509 ;; XXX Experimental function for the vc-dired replacement.
510 (defun vc-hg-dir-status (dir update-function status-buffer)
511 "Return a list of conses (file . state) for DIR."
512 (with-current-buffer
513 (get-buffer-create
514 (expand-file-name " *VC-hg* tmp status" dir))
515 (vc-hg-command (current-buffer) 'async dir "status")
516 (vc-exec-after
517 `(vc-hg-after-dir-status (quote ,update-function) ,status-buffer))))
512 518
513 ;; XXX this adds another top level menu, instead figure out how to 519 ;; XXX this adds another top level menu, instead figure out how to
514 ;; replace the Log-View menu. 520 ;; replace the Log-View menu.
515 (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map 521 (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map
516 "Hg-outgoing Display Menu" 522 "Hg-outgoing Display Menu"