aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandre Julliard2008-04-13 18:06:35 +0000
committerAlexandre Julliard2008-04-13 18:06:35 +0000
commitfb0ac090ccac3142e52615a569286158d3a3d952 (patch)
tree58438e6b0fb7217311550ab83e4ee1b5a003d53f
parent48f7d2134fc8503360449814b283c817cd1a608b (diff)
downloademacs-fb0ac090ccac3142e52615a569286158d3a3d952.tar.gz
emacs-fb0ac090ccac3142e52615a569286158d3a3d952.zip
(vc-status-update): Revert an incorrect rewrite. Add some
comments. (vc-status-refresh-files): New function. (vc-status-refresh): Use `vc-status-refresh-files' to refresh the state of up-to-date files. (vc-default-dir-status-files): New function.
-rw-r--r--lisp/vc.el130
1 files changed, 82 insertions, 48 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index b5d98384c6a..1abc1207e51 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -184,12 +184,20 @@
184;; when all the results have been computed. 184;; when all the results have been computed.
185;; To provide more backend specific functionality for `vc-status' 185;; To provide more backend specific functionality for `vc-status'
186;; the following functions might be needed: `status-extra-headers', 186;; the following functions might be needed: `status-extra-headers',
187;; `status-printer', `extra-status-menu' and `status-fileinfo-extra'. 187;; `status-printer', `extra-status-menu' and `dir-status-files'.
188;; This function is used by `vc-status', a replacement for 188;; This function is used by `vc-status', a replacement for
189;; `vc-dired'. vc-status is still under development, and is NOT 189;; `vc-dired'. vc-status is still under development, and is NOT
190;; feature complete. As such, the requirements for this function 190;; feature complete. As such, the requirements for this function
191;; might change. This is a replacement for `dir-state'. 191;; might change. This is a replacement for `dir-state'.
192;; 192;;
193;; - dir-status-files (dir files default-state update-function)
194;;
195;; This function is identical to dir-status except that it should
196;; only report status for the specified FILES. Also it needs to
197;; report on all requested files, including up-to-date or ignored
198;; files. If not provided, the default is to consider that the files
199;; are in DEFAULT-STATE.
200;;
193;; - status-extra-headers (dir) 201;; - status-extra-headers (dir)
194;; 202;;
195;; Return a string that will be added to the *vc-status* buffer header. 203;; Return a string that will be added to the *vc-status* buffer header.
@@ -643,11 +651,6 @@
643;; - vc-status needs a command to insert a file entry in the status 651;; - vc-status needs a command to insert a file entry in the status
644;; display, similar to `cvs-mode-insert'. 652;; display, similar to `cvs-mode-insert'.
645;; 653;;
646;; - the dir-status backend function should take as an argument an
647;; optional fileset, and should return the results just for that
648;; fileset. This can be used to speed up status buffer updates
649;; after VC operations.
650;;
651;; - vc-status: refresh should not completely wipe out the current 654;; - vc-status: refresh should not completely wipe out the current
652;; contents of the vc-status buffer. 655;; contents of the vc-status buffer.
653;; 656;;
@@ -2715,7 +2718,9 @@ With prefix arg READ-SWITCHES, specify a value to override
2715 state 2718 state
2716 ;; For storing backend specific information. 2719 ;; For storing backend specific information.
2717 extra 2720 extra
2718 marked) 2721 marked
2722 ;; To keep track of not updated files during a global refresh
2723 needs-update)
2719 2724
2720(defvar vc-status nil) 2725(defvar vc-status nil)
2721 2726
@@ -2998,9 +3003,8 @@ specific headers."
2998 3003
2999(put 'vc-status-mode 'mode-class 'special) 3004(put 'vc-status-mode 'mode-class 'special)
3000 3005
3001(defun vc-status-update (entries buffer &optional noinsert) 3006(defun vc-status-update (entries buffer)
3002 "Update BUFFER's ewoc from the list of ENTRIES. 3007 "Update BUFFER's ewoc from the list of ENTRIES."
3003If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
3004 ;; Add ENTRIES to the vc-status buffer BUFFER. 3008 ;; Add ENTRIES to the vc-status buffer BUFFER.
3005 (with-current-buffer buffer 3009 (with-current-buffer buffer
3006 ;; Insert the entries sorted by name into the ewoc. 3010 ;; Insert the entries sorted by name into the ewoc.
@@ -3009,35 +3013,64 @@ If NOINSERT, ignore elements on ENTRIES which are not in the ewoc."
3009 (setq entries (sort entries 3013 (setq entries (sort entries
3010 (lambda (entry1 entry2) 3014 (lambda (entry1 entry2)
3011 (string-lessp (car entry1) (car entry2))))) 3015 (string-lessp (car entry1) (car entry2)))))
3012 (let ((entry (car entries)) 3016 (let ((entry (pop entries))
3013 (node (ewoc-nth vc-status 0))) 3017 (node (ewoc-nth vc-status 0)))
3014 (while (and entry node) 3018 (while entry
3015 (let ((entryfile (car entry)) 3019 (let ((file (car entry)))
3016 (nodefile (vc-status-fileinfo->name (ewoc-data node)))) 3020 ;; Note: we always keep node pointing to the last inserted entry
3017 (cond 3021 ;; in order to catch duplicates in the entries list
3018 ((string-lessp nodefile entryfile) 3022 (cond ((not node)
3019 (setq node (ewoc-next vc-status node))) 3023 (setq node (ewoc-enter-last vc-status
3020 ((string-lessp nodefile entryfile) 3024 (apply 'vc-status-create-fileinfo entry)))
3021 (unless noinsert 3025 (setq entry (pop entries)))
3022 (ewoc-enter-before vc-status node 3026 ((string-lessp (vc-status-fileinfo->name (ewoc-data node)) file)
3023 (apply 'vc-status-create-fileinfo entry))) 3027 (setq node (ewoc-next vc-status node)))
3024 (setq entries (cdr entries) entry (car entries))) 3028 ((string-equal (vc-status-fileinfo->name (ewoc-data node)) file)
3025 (t 3029 (setf (vc-status-fileinfo->state (ewoc-data node)) (nth 1 entry))
3026 (setf (vc-status-fileinfo->state (ewoc-data node)) (nth 1 entry)) 3030 (setf (vc-status-fileinfo->extra (ewoc-data node)) (nth 2 entry))
3027 (setf (vc-status-fileinfo->extra (ewoc-data node)) (nth 2 entry)) 3031 (setf (vc-status-fileinfo->needs-update (ewoc-data node)) nil)
3028 (ewoc-invalidate vc-status node) 3032 (ewoc-invalidate vc-status node)
3029 (setq entries (cdr entries) entry (car entries)) 3033 (setq entry (pop entries)))
3030 (setq node (ewoc-next vc-status node)))))) 3034 (t
3031 (unless (or node noinsert) 3035 (setq node (ewoc-enter-before vc-status node
3032 ;; We're past the last node, all remaining entries go to the end. 3036 (apply 'vc-status-create-fileinfo entry)))
3033 (while entries 3037 (setq entry (pop entries)))))))))
3034 (ewoc-enter-last vc-status
3035 (apply 'vc-status-create-fileinfo (pop entries))))))))
3036 3038
3037(defun vc-status-busy () 3039(defun vc-status-busy ()
3038 (and (buffer-live-p vc-status-process-buffer) 3040 (and (buffer-live-p vc-status-process-buffer)
3039 (get-buffer-process vc-status-process-buffer))) 3041 (get-buffer-process vc-status-process-buffer)))
3040 3042
3043(defun vc-status-refresh-files (files default-state)
3044 "Refresh some files in the VC status buffer."
3045 (let ((backend (vc-responsible-backend default-directory))
3046 (status-buffer (current-buffer))
3047 (def-dir default-directory))
3048 (vc-set-mode-line-busy-indicator)
3049 ;; Call the `dir-status-file' backend function.
3050 ;; `dir-status-file' is supposed to be asynchronous.
3051 ;; It should compute the results, and then call the function
3052 ;; passed as an argument in order to update the vc-status buffer
3053 ;; with the results.
3054 (unless (buffer-live-p vc-status-process-buffer)
3055 (setq vc-status-process-buffer
3056 (generate-new-buffer (format " *VC-%s* tmp status" backend))))
3057 (lexical-let ((buffer (current-buffer)))
3058 (with-current-buffer vc-status-process-buffer
3059 (cd def-dir)
3060 (erase-buffer)
3061 (vc-call-backend
3062 backend 'dir-status-files def-dir files default-state
3063 (lambda (entries &optional more-to-come)
3064 ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
3065 ;; If MORE-TO-COME is true, then more updates will come from
3066 ;; the asynchronous process.
3067 (with-current-buffer buffer
3068 (vc-status-update entries buffer)
3069 (unless more-to-come
3070 (setq mode-line-process nil)
3071 ;; Remove the ones that haven't been updated at all
3072 (ewoc-filter vc-status (lambda (info) (not (vc-status-fileinfo->needs-update info))))))))))))
3073
3041(defun vc-status-refresh () 3074(defun vc-status-refresh ()
3042 "Refresh the contents of the VC status buffer. 3075 "Refresh the contents of the VC status buffer.
3043Throw an error if another update process is in progress." 3076Throw an error if another update process is in progress."
@@ -3062,8 +3095,9 @@ Throw an error if another update process is in progress."
3062 (unless (buffer-live-p vc-status-process-buffer) 3095 (unless (buffer-live-p vc-status-process-buffer)
3063 (setq vc-status-process-buffer 3096 (setq vc-status-process-buffer
3064 (generate-new-buffer (format " *VC-%s* tmp status" backend)))) 3097 (generate-new-buffer (format " *VC-%s* tmp status" backend))))
3065 (lexical-let ((oldentries (ewoc-collect vc-status (lambda (_) t))) 3098 ;; set the needs-update flag on all entries
3066 (buffer (current-buffer))) 3099 (ewoc-map (lambda (info) (setf (vc-status-fileinfo->needs-update info) t) nil) vc-status)
3100 (lexical-let ((buffer (current-buffer)))
3067 (with-current-buffer vc-status-process-buffer 3101 (with-current-buffer vc-status-process-buffer
3068 (cd def-dir) 3102 (cd def-dir)
3069 (erase-buffer) 3103 (erase-buffer)
@@ -3074,20 +3108,16 @@ Throw an error if another update process is in progress."
3074 ;; If MORE-TO-COME is true, then more updates will come from 3108 ;; If MORE-TO-COME is true, then more updates will come from
3075 ;; the asynchronous process. 3109 ;; the asynchronous process.
3076 (with-current-buffer buffer 3110 (with-current-buffer buffer
3077 (dolist (entry entries)
3078 (setq oldentries
3079 (delq (member (car entry) oldentries) oldentries)))
3080 (vc-status-update entries buffer) 3111 (vc-status-update entries buffer)
3081 (ewoc-goto-node vc-status (ewoc-nth vc-status 0))
3082 ;; No more updates are expected from the asynchronous process.
3083 (unless more-to-come 3112 (unless more-to-come
3084 ;; We are done, turn off the mode-line "in progress" message. 3113 (let ((remaining
3085 (setq mode-line-process nil) 3114 (ewoc-collect vc-status
3086 ;; Update old entries that were not mentioned, and were 3115 (lambda (info) (vc-status-fileinfo->needs-update info)))))
3087 ;; hence implicitly given as uptodate. 3116 (if remaining
3088 (dolist (entry oldentries) 3117 (vc-status-refresh-files
3089 (setf (vc-status-fileinfo->state entry) 'up-to-date)) 3118 (mapcar (lambda (info) (vc-status-fileinfo->name info)) remaining)
3090 (vc-status-update oldentries buffer 'noinsert)))))))))) 3119 'up-to-date)
3120 (setq mode-line-process nil))))))))))))
3091 3121
3092(defun vc-status-kill-dir-status-process () 3122(defun vc-status-kill-dir-status-process ()
3093 "Kill the temporary buffer and associated process." 3123 "Kill the temporary buffer and associated process."
@@ -3993,6 +4023,10 @@ to provide the `find-revision' operation instead."
3993 4023
3994(defalias 'vc-default-revision-completion-table 'ignore) 4024(defalias 'vc-default-revision-completion-table 'ignore)
3995 4025
4026(defun vc-default-dir-status-files (backend dir files default-state update-function)
4027 (funcall update-function
4028 (mapcar (lambda (file) (list file default-state)) files)))
4029
3996(defun vc-check-headers () 4030(defun vc-check-headers ()
3997 "Check if the current file has any headers in it." 4031 "Check if the current file has any headers in it."
3998 (interactive) 4032 (interactive)