From: Eric S. Raymond Date: Tue, 1 Jan 2008 11:17:37 +0000 (+0000) Subject: * vc.el (vc-dired-hook): Speed tuning. Replace a vc-backend call X-Git-Tag: emacs-pretest-23.0.90~8748 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c59a24425bd684d22213781c70c2a8a5b01b3aa0;p=emacs.git * vc.el (vc-dired-hook): Speed tuning. Replace a vc-backend call with vc-state. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 29eff1f1d2a..582cfb115fc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2008-01-01 Eric S. Raymond + + * vc.el (vc-dired-hook): Speed tuning. Replace a vc-backend call + with vc-state. + 2007-12-31 Tom Tromey * emacs-lisp/elp.el (elp-results): Use header-line-format for diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el index c1261c5d0a4..96bc1284f76 100644 --- a/lisp/vc-svn.el +++ b/lisp/vc-svn.el @@ -536,6 +536,10 @@ and that it passes `vc-svn-global-switches' to it before FLAGS." nil) (message "There are unresolved conflicts in this file"))) +(defun vc-file-setprop2 (f p v) + (message (format "On file %s. setting property %s to %s" f p v)) + (sit-for 2)) + (defun vc-svn-parse-status (&optional filename) "Parse output of \"svn status\" command in the current buffer. Set file properties accordingly. Unless FILENAME is non-nil, parse only @@ -544,7 +548,7 @@ information about FILENAME and return its status." (goto-char (point-min)) (while (re-search-forward ;; Ignore the files with status X. - "^[ ACDGIMR!?~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t) + "^\\? +|^[ ACDGIMR!~][ MC][ L][ +][ S]..\\([ *]\\) +\\([-0-9]+\\) +\\([0-9?]+\\) +\\([^ ]+\\) +" nil t) ;; If the username contains spaces, the output format is ambiguous, ;; so don't trust the output's filename unless we have to. (setq file (or filename @@ -552,37 +556,37 @@ information about FILENAME and return its status." (buffer-substring (point) (line-end-position))))) (setq status (char-after (line-beginning-position))) (if (eq status ??) - (vc-file-setprop file 'vc-state 'unregistered) + (vc-file-setprop2 file 'vc-state 'unregistered) ;; `vc-BACKEND-registered' must not set vc-backend, ;; which is instead set in vc-registered. - (unless filename (vc-file-setprop file 'vc-backend 'SVN)) + (unless filename (vc-file-setprop2 file 'vc-backend 'SVN)) ;; Use the last-modified revision, so that searching in vc-print-log ;; output works. - (vc-file-setprop file 'vc-working-revision (match-string 3)) + (vc-file-setprop2 file 'vc-working-revision (match-string 3)) ;; Remember Svn's own status. - (vc-file-setprop file 'vc-svn-status status) - (vc-file-setprop + (vc-file-setprop2 file 'vc-svn-status status) + (vc-file-setprop2 file 'vc-state (cond ((eq status ?\ ) (if (eq (char-after (match-beginning 1)) ?*) 'needs-patch - (vc-file-setprop file 'vc-checkout-time + (vc-file-setprop2 file 'vc-checkout-time (nth 5 (file-attributes file))) 'up-to-date)) ((eq status ?A) ;; If the file was actually copied, (match-string 2) is "-". - (vc-file-setprop file 'vc-working-revision "0") - (vc-file-setprop file 'vc-checkout-time 0) + (vc-file-setprop2 file 'vc-working-revision "0") + (vc-file-setprop2 file 'vc-checkout-time 0) 'added) ((memq status '(?M ?C)) (if (eq (char-after (match-beginning 1)) ?*) 'needs-merge 'edited)) ((eq status ?I) - (vc-file-setprop file 'vc-state 'ignored)) + (vc-file-setprop2 file 'vc-state 'ignored)) ((eq status ?R) - (vc-file-setprop file 'vc-state 'removed)) + (vc-file-setprop2 file 'vc-state 'removed)) (t 'edited))))) (if filename (vc-file-getprop filename 'vc-state)))) diff --git a/lisp/vc.el b/lisp/vc.el index 621802cf4a9..ddcb53a0cb6 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -2393,27 +2393,25 @@ Called by dired after any portion of a vc-dired buffer has been read in." (t (vc-dired-reformat-line nil) (forward-line 1)))) - ;; try to head off calling the expensive state query - + ;; Try to head off calling the expensive state query - ;; ignore object files, TeX intermediate files, and so forth. ((vc-dired-ignorable-p filename) (dired-kill-line)) - ;; ordinary file -- call the (possibly expensive) state query - (t - (let ((backend (vc-backend filename))) - (cond - ;; Not registered - ((not backend) - (if vc-dired-terse-mode - (dired-kill-line) - (vc-dired-reformat-line "?") - (forward-line 1))) - ;; Either we're in non-terse mode or it's out of date - ((not (and vc-dired-terse-mode (vc-up-to-date-p filename))) - (vc-dired-reformat-line (vc-call dired-state-info filename)) - (forward-line 1)) - ;; Remaining cases are under version control but uninteresting - (t - (dired-kill-line))))))) + ;; Ordinary file -- call the (possibly expensive) state query + ;; + ;; First case: unregistered or unknown. (Unknown shouldn't happen here) + ((member (vc-state filename) '(nil unregistered)) + (if vc-dired-terse-mode + (dired-kill-line) + (vc-dired-reformat-line "?") + (forward-line 1))) + ;; Either we're in non-terse mode or it's out of date + ((not (and vc-dired-terse-mode (vc-up-to-date-p filename))) + (vc-dired-reformat-line (vc-call dired-state-info filename)) + (forward-line 1)) + ;; Remaining cases are under version control but uninteresting + (t + (dired-kill-line)))) ;; any other line (t (forward-line 1)))) (vc-dired-purge))