summaryrefslogtreecommitdiff
path: root/lisp/vc/vc-dispatcher.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2011-01-29 16:19:21 -0500
committerChong Yidong <cyd@stupidchicken.com>2011-01-29 16:19:21 -0500
commita2b6e5d60b10c6baa3fbc36bfb158342c1c424ab (patch)
tree408b3a15fdee9f1443aa155efeef376df69e12de /lisp/vc/vc-dispatcher.el
parentb6bcd04894c08ef2ec8ad7569f028fc85793f8a6 (diff)
downloademacs-a2b6e5d60b10c6baa3fbc36bfb158342c1c424ab.tar.gz
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.
Diffstat (limited to 'lisp/vc/vc-dispatcher.el')
-rw-r--r--lisp/vc/vc-dispatcher.el28
1 files changed, 27 insertions, 1 deletions
diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index 53b0d9ef8b3..c4e0dbfadac 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -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,