diff options
| author | Dan Nicolaescu | 2008-03-21 06:29:04 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2008-03-21 06:29:04 +0000 |
| commit | e345c46e5613f29d17a1c9e6c663c80925e33129 (patch) | |
| tree | 0e7d9d45f516014012509aefb5fe75f5aec6b4ed | |
| parent | 12cb746e0a408c66ccb12c89be0fd9505d73d2b1 (diff) | |
| download | emacs-e345c46e5613f29d17a1c9e6c663c80925e33129.tar.gz emacs-e345c46e5613f29d17a1c9e6c663c80925e33129.zip | |
(vc-git-status-result): New variable.
(vc-git-dir-status): Split out ...
(vc-git-after-dir-status-stage1, vc-git-after-dir-status-stage2):
... these new functions and work asynchronously.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/vc-git.el | 57 |
2 files changed, 42 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 006f0a603bd..6c7a0c979f3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2008-03-21 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc-git.el (vc-git-status-result): New variable. | ||
| 4 | (vc-git-dir-status): Split out ... | ||
| 5 | (vc-git-after-dir-status-stage1, vc-git-after-dir-status-stage2): | ||
| 6 | ... these new functions and work asynchronously. | ||
| 7 | |||
| 1 | 2008-03-21 Alexandre Julliard <julliard@winehq.org> | 8 | 2008-03-21 Alexandre Julliard <julliard@winehq.org> |
| 2 | 9 | ||
| 3 | * vc-git.el (vc-git-after-dir-status): Remove. | 10 | * vc-git.el (vc-git-after-dir-status): Remove. |
diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 79a20cb62d2..888d2aaddf2 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el | |||
| @@ -207,6 +207,36 @@ | |||
| 207 | ;; fall back to the default VC representation | 207 | ;; fall back to the default VC representation |
| 208 | (vc-default-dired-state-info 'Git file)))) | 208 | (vc-default-dired-state-info 'Git file)))) |
| 209 | 209 | ||
| 210 | ;; Variable used to keep the intermediate results for vc-git-status. | ||
| 211 | (defvar vc-git-status-result nil) | ||
| 212 | |||
| 213 | (defun vc-git-after-dir-status-stage2 (update-function status-buffer) | ||
| 214 | (goto-char (point-min)) | ||
| 215 | (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) | ||
| 216 | (push (cons (match-string 1) 'unregistered) vc-git-status-result)) | ||
| 217 | (funcall update-function (nreverse vc-git-status-result) status-buffer) | ||
| 218 | ;; Remove the temporary buffer. | ||
| 219 | (kill-buffer (current-buffer))) | ||
| 220 | |||
| 221 | (defun vc-git-after-dir-status-stage1 (update-function status-buffer) | ||
| 222 | (goto-char (point-min)) | ||
| 223 | (while (re-search-forward | ||
| 224 | ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0" | ||
| 225 | nil t 1) | ||
| 226 | (let ((filename (match-string 2)) | ||
| 227 | (status (case (string-to-char( match-string 1)) | ||
| 228 | (?M 'edited) | ||
| 229 | (?A 'added) | ||
| 230 | (?D 'removed) | ||
| 231 | (?U 'edited) ;; FIXME | ||
| 232 | (?T 'edited)))) ;; FIXME | ||
| 233 | (push (cons filename status) vc-git-status-result))) | ||
| 234 | (erase-buffer) | ||
| 235 | (vc-git-command (current-buffer) 'async nil "ls-files" "-z" "-o" | ||
| 236 | "--directory" "--no-empty-directory" "--exclude-standard") | ||
| 237 | (vc-exec-after | ||
| 238 | `(vc-git-after-dir-status-stage2 (quote ,update-function) ,status-buffer))) | ||
| 239 | |||
| 210 | (defun vc-git-dir-status (dir update-function status-buffer) | 240 | (defun vc-git-dir-status (dir update-function status-buffer) |
| 211 | "Return a list of conses (file . state) for DIR." | 241 | "Return a list of conses (file . state) for DIR." |
| 212 | ;; Further things that would have to be fixed later: | 242 | ;; Further things that would have to be fixed later: |
| @@ -216,29 +246,12 @@ | |||
| 216 | (with-current-buffer | 246 | (with-current-buffer |
| 217 | (get-buffer-create | 247 | (get-buffer-create |
| 218 | (expand-file-name " *VC-Git* tmp status" dir)) | 248 | (expand-file-name " *VC-Git* tmp status" dir)) |
| 249 | (set (make-local-variable 'vc-git-status-result) nil) | ||
| 219 | (cd dir) | 250 | (cd dir) |
| 220 | (let (result) | 251 | (erase-buffer) |
| 221 | (erase-buffer) | 252 | (vc-git-command (current-buffer) 'async nil "diff-index" "-z" "HEAD") |
| 222 | (vc-git-command (current-buffer) 0 nil "diff-index" "-z" "HEAD") | 253 | (vc-exec-after |
| 223 | (goto-char (point-min)) | 254 | `(vc-git-after-dir-status-stage1 (quote ,update-function) ,status-buffer)) |
| 224 | (while (re-search-forward | ||
| 225 | ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} \\([ADMUT]\\)\0\\([^\0]+\\)\0" | ||
| 226 | nil t 1) | ||
| 227 | (let ((filename (match-string 2)) | ||
| 228 | (status (case (string-to-char( match-string 1)) | ||
| 229 | (?M 'edited) | ||
| 230 | (?A 'added) | ||
| 231 | (?D 'removed) | ||
| 232 | (?U 'edited) ;; FIXME | ||
| 233 | (?T 'edited)))) ;; FIXME | ||
| 234 | (push (cons filename status) result))) | ||
| 235 | (erase-buffer) | ||
| 236 | (vc-git-command (current-buffer) 0 nil "ls-files" "-z" "-o" | ||
| 237 | "--directory" "--no-empty-directory" "--exclude-standard") | ||
| 238 | (goto-char (point-min)) | ||
| 239 | (while (re-search-forward "\\([^\0]*?\\)\0" nil t 1) | ||
| 240 | (push (cons (match-string 1) 'unregistered) result)) | ||
| 241 | (funcall update-function (nreverse result) status-buffer)) | ||
| 242 | (current-buffer))) | 255 | (current-buffer))) |
| 243 | 256 | ||
| 244 | ;;; STATE-CHANGING FUNCTIONS | 257 | ;;; STATE-CHANGING FUNCTIONS |