comparison lisp/vc-bzr.el @ 106269:e90925cbde07

(vc-bzr-annotate-command): Make operation asynchronous.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Thu, 26 Nov 2009 14:50:28 +0000
parents 2bed02fa3041
children d1166d927ca2
comparison
equal deleted inserted replaced
106268:da7a85775258 106269:e90925cbde07
549 549
550 (defun vc-bzr-annotate-command (file buffer &optional revision) 550 (defun vc-bzr-annotate-command (file buffer &optional revision)
551 "Prepare BUFFER for `vc-annotate' on FILE. 551 "Prepare BUFFER for `vc-annotate' on FILE.
552 Each line is tagged with the revision number, which has a `help-echo' 552 Each line is tagged with the revision number, which has a `help-echo'
553 property containing author and date information." 553 property containing author and date information."
554 (apply #'vc-bzr-command "annotate" buffer 0 file "--long" "--all" 554 (apply #'vc-bzr-command "annotate" buffer 'async file "--long" "--all"
555 (if revision (list "-r" revision))) 555 (if revision (list "-r" revision)))
556 (with-current-buffer buffer 556 (lexical-let ((table (make-hash-table :test 'equal)))
557 ;; Store the tags for the annotated source lines in a hash table 557 (set-process-filter
558 ;; to allow saving space by sharing the text properties. 558 (get-buffer-process buffer)
559 (setq vc-bzr-annotation-table (make-hash-table :test 'equal)) 559 (lambda (proc string)
560 (goto-char (point-min)) 560 (when (process-buffer proc)
561 (while (re-search-forward "^\\( *[0-9.]+ *\\) \\([^\n ]+\\) +\\([0-9]\\{8\\}\\) |" 561 (with-current-buffer (process-buffer proc)
562 nil t) 562 (setq string (concat (process-get proc :vc-left-over) string))
563 (let* ((rev (match-string 1)) 563 (while (string-match "^\\( *[0-9.]+ *\\) \\([^\n ]+\\) +\\([0-9]\\{8\\}\\)\\( |.*\n\\)" string)
564 (author (match-string 2)) 564 (let* ((rev (match-string 1 string))
565 (date (match-string 3)) 565 (author (match-string 2 string))
566 (key (match-string 0)) 566 (date (match-string 3 string))
567 (tag (gethash key vc-bzr-annotation-table))) 567 (key (substring string (match-beginning 0)
568 (match-beginning 4)))
569 (line (match-string 4 string))
570 (tag (gethash key table))
571 (inhibit-read-only t))
572 (setq string (substring string (match-end 0)))
568 (unless tag 573 (unless tag
569 (setq tag (propertize rev 'help-echo (concat "Author: " author 574 (setq tag (propertize rev 'help-echo (concat "Author: " author
570 ", date: " date) 575 ", date: " date)
571 'mouse-face 'highlight)) 576 'mouse-face 'highlight))
572 (puthash key tag vc-bzr-annotation-table)) 577 (puthash key tag table))
573 (replace-match "") 578 (goto-char (process-mark proc))
574 (insert tag " |"))))) 579 (insert tag line)
580 (move-marker (process-mark proc) (point))))
581 (process-put proc :vc-left-over string)))))))
575 582
576 (declare-function vc-annotate-convert-time "vc-annotate" (time)) 583 (declare-function vc-annotate-convert-time "vc-annotate" (time))
577 584
578 (defun vc-bzr-annotate-time () 585 (defun vc-bzr-annotate-time ()
579 (when (re-search-forward "^ *[0-9.]+ +|" nil t) 586 (when (re-search-forward "^ *[0-9.]+ +|" nil t)