1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Refresh Dired and VC-dir buffers after vc-pull and vc-merge.

* vc/vc-dispatcher.el (vc-set-async-update): New function for
updating Dired or VC-dir buffers after async command completes.

* vc/vc-bzr.el (vc-bzr-async-command): Return the process buffer.
(vc-bzr-pull, vc-bzr-merge-branch): Use vc-set-async-update.

* vc/vc-git.el (vc-git-merge-branch): Add FETCH_HEAD to branch
completions if it exists.  Use vc-set-async-update.
(vc-git-pull): Use vc-set-async-update.

* vc/vc-hg.el (vc-hg-pull): Fix default-contents arg to
read-shell-command.  Use vc-set-async-update.
(vc-hg-merge-branch): Use vc-set-async-update.
This commit is contained in:
Chong Yidong 2011-01-29 16:19:21 -05:00
parent b6bcd04894
commit a2b6e5d60b
5 changed files with 86 additions and 20 deletions

View file

@ -382,7 +382,33 @@ Display the buffer in some window, but don't select it."
(apply 'vc-do-command t 'async command nil args)))
(setq window (display-buffer buffer))
(if window
(set-window-start window new-window-start))))
(set-window-start window new-window-start))
buffer))
(defun vc-set-async-update (process-buffer)
"Set a `vc-exec-after' action appropriate to the current buffer.
This action will update the current buffer after the current
asynchronous VC command has completed. PROCESS-BUFFER is the
buffer for the asynchronous VC process.
If the current buffer is a VC Dir buffer, call `vc-dir-refresh'.
If the current buffer is a Dired buffer, revert it."
(let* ((buf (current-buffer))
(tick (buffer-modified-tick buf)))
(cond
((derived-mode-p 'vc-dir-mode)
(with-current-buffer process-buffer
(vc-exec-after
`(if (buffer-live-p ,buf)
(with-current-buffer ,buf
(vc-dir-refresh))))))
((derived-mode-p 'dired-mode)
(with-current-buffer process-buffer
(vc-exec-after
`(and (buffer-live-p ,buf)
(= (buffer-modified-tick ,buf) ,tick)
(with-current-buffer ,buf
(revert-buffer)))))))))
;; These functions are used to ensure that the view the user sees is up to date
;; even if the dispatcher client mode has messed with file contents (as in,