diff options
| author | Chong Yidong | 2011-01-29 16:19:21 -0500 |
|---|---|---|
| committer | Chong Yidong | 2011-01-29 16:19:21 -0500 |
| commit | a2b6e5d60b10c6baa3fbc36bfb158342c1c424ab (patch) | |
| tree | 408b3a15fdee9f1443aa155efeef376df69e12de | |
| parent | b6bcd04894c08ef2ec8ad7569f028fc85793f8a6 (diff) | |
| download | emacs-a2b6e5d60b10c6baa3fbc36bfb158342c1c424ab.tar.gz emacs-a2b6e5d60b10c6baa3fbc36bfb158342c1c424ab.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 16 | ||||
| -rw-r--r-- | lisp/vc/vc-bzr.el | 15 | ||||
| -rw-r--r-- | lisp/vc/vc-dispatcher.el | 28 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 22 | ||||
| -rw-r--r-- | lisp/vc/vc-hg.el | 25 |
5 files changed, 86 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9ca1dd55250..c9bdafebe8a 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | 2011-01-29 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * vc/vc-dispatcher.el (vc-set-async-update): New function for | ||
| 4 | updating Dired or VC-dir buffers after async command completes. | ||
| 5 | |||
| 6 | * vc/vc-bzr.el (vc-bzr-async-command): Return the process buffer. | ||
| 7 | (vc-bzr-pull, vc-bzr-merge-branch): Use vc-set-async-update. | ||
| 8 | |||
| 9 | * vc/vc-git.el (vc-git-merge-branch): Add FETCH_HEAD to branch | ||
| 10 | completions if it exists. Use vc-set-async-update. | ||
| 11 | (vc-git-pull): Use vc-set-async-update. | ||
| 12 | |||
| 13 | * vc/vc-hg.el (vc-hg-pull): Fix default-contents arg to | ||
| 14 | read-shell-command. Use vc-set-async-update. | ||
| 15 | (vc-hg-merge-branch): Use vc-set-async-update. | ||
| 16 | |||
| 1 | 2011-01-29 Daiki Ueno <ueno@unixuser.org> | 17 | 2011-01-29 Daiki Ueno <ueno@unixuser.org> |
| 2 | 18 | ||
| 3 | * epg.el (epg--status-KEYEXPIRED, epg--status-KEYREVOKED): Don't | 19 | * epg.el (epg--status-KEYEXPIRED, epg--status-KEYREVOKED): Don't |
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 31893645a62..9f86a28a575 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -100,14 +100,15 @@ Invoke the bzr command adding `BZR_PROGRESS_BAR=none' and | |||
| 100 | `LC_MESSAGES=C' to the environment. | 100 | `LC_MESSAGES=C' to the environment. |
| 101 | Use the current Bzr root directory as the ROOT argument to | 101 | Use the current Bzr root directory as the ROOT argument to |
| 102 | `vc-do-async-command', and specify an output buffer named | 102 | `vc-do-async-command', and specify an output buffer named |
| 103 | \"*vc-bzr : ROOT*\"." | 103 | \"*vc-bzr : ROOT*\". Return this buffer." |
| 104 | (let* ((process-environment | 104 | (let* ((process-environment |
| 105 | (list* "BZR_PROGRESS_BAR=none" "LC_MESSAGES=C" | 105 | (list* "BZR_PROGRESS_BAR=none" "LC_MESSAGES=C" |
| 106 | process-environment)) | 106 | process-environment)) |
| 107 | (root (vc-bzr-root default-directory)) | 107 | (root (vc-bzr-root default-directory)) |
| 108 | (buffer (format "*vc-bzr : %s*" (expand-file-name root)))) | 108 | (buffer (format "*vc-bzr : %s*" (expand-file-name root)))) |
| 109 | (apply 'vc-do-async-command buffer root | 109 | (apply 'vc-do-async-command buffer root |
| 110 | vc-bzr-program bzr-command args))) | 110 | vc-bzr-program bzr-command args) |
| 111 | buffer)) | ||
| 111 | 112 | ||
| 112 | ;;;###autoload | 113 | ;;;###autoload |
| 113 | (defconst vc-bzr-admin-dirname ".bzr" | 114 | (defconst vc-bzr-admin-dirname ".bzr" |
| @@ -297,14 +298,15 @@ prompt for the Bzr command to run." | |||
| 297 | (when (or prompt (not (or bound parent))) | 298 | (when (or prompt (not (or bound parent))) |
| 298 | (setq args (split-string | 299 | (setq args (split-string |
| 299 | (read-shell-command | 300 | (read-shell-command |
| 300 | "Run Bzr (like this): " | 301 | "Bzr pull command: " |
| 301 | (concat vc-bzr-program " " command) | 302 | (concat vc-bzr-program " " command) |
| 302 | 'vc-bzr-history) | 303 | 'vc-bzr-history) |
| 303 | " " t)) | 304 | " " t)) |
| 304 | (setq vc-bzr-program (car args) | 305 | (setq vc-bzr-program (car args) |
| 305 | command (cadr args) | 306 | command (cadr args) |
| 306 | args (cddr args))) | 307 | args (cddr args))) |
| 307 | (apply 'vc-bzr-async-command command args))) | 308 | (vc-set-async-update |
| 309 | (apply 'vc-bzr-async-command command args)))) | ||
| 308 | 310 | ||
| 309 | (defun vc-bzr-merge-branch () | 311 | (defun vc-bzr-merge-branch () |
| 310 | "Merge another Bzr branch into the current one. | 312 | "Merge another Bzr branch into the current one. |
| @@ -328,7 +330,7 @@ default if it is available." | |||
| 328 | (cmd | 330 | (cmd |
| 329 | (split-string | 331 | (split-string |
| 330 | (read-shell-command | 332 | (read-shell-command |
| 331 | "Run Bzr (like this): " | 333 | "Bzr merge command: " |
| 332 | (concat vc-bzr-program " merge --pull" | 334 | (concat vc-bzr-program " merge --pull" |
| 333 | (if location (concat " " location) "")) | 335 | (if location (concat " " location) "")) |
| 334 | 'vc-bzr-history) | 336 | 'vc-bzr-history) |
| @@ -336,7 +338,8 @@ default if it is available." | |||
| 336 | (vc-bzr-program (car cmd)) | 338 | (vc-bzr-program (car cmd)) |
| 337 | (command (cadr cmd)) | 339 | (command (cadr cmd)) |
| 338 | (args (cddr cmd))) | 340 | (args (cddr cmd))) |
| 339 | (apply 'vc-bzr-async-command command args))) | 341 | (vc-set-async-update |
| 342 | (apply 'vc-bzr-async-command command args)))) | ||
| 340 | 343 | ||
| 341 | (defun vc-bzr-status (file) | 344 | (defun vc-bzr-status (file) |
| 342 | "Return FILE status according to Bzr. | 345 | "Return FILE status according to Bzr. |
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." | |||
| 382 | (apply 'vc-do-command t 'async command nil args))) | 382 | (apply 'vc-do-command t 'async command nil args))) |
| 383 | (setq window (display-buffer buffer)) | 383 | (setq window (display-buffer buffer)) |
| 384 | (if window | 384 | (if window |
| 385 | (set-window-start window new-window-start)))) | 385 | (set-window-start window new-window-start)) |
| 386 | buffer)) | ||
| 387 | |||
| 388 | (defun vc-set-async-update (process-buffer) | ||
| 389 | "Set a `vc-exec-after' action appropriate to the current buffer. | ||
| 390 | This action will update the current buffer after the current | ||
| 391 | asynchronous VC command has completed. PROCESS-BUFFER is the | ||
| 392 | buffer for the asynchronous VC process. | ||
| 393 | |||
| 394 | If the current buffer is a VC Dir buffer, call `vc-dir-refresh'. | ||
| 395 | If the current buffer is a Dired buffer, revert it." | ||
| 396 | (let* ((buf (current-buffer)) | ||
| 397 | (tick (buffer-modified-tick buf))) | ||
| 398 | (cond | ||
| 399 | ((derived-mode-p 'vc-dir-mode) | ||
| 400 | (with-current-buffer process-buffer | ||
| 401 | (vc-exec-after | ||
| 402 | `(if (buffer-live-p ,buf) | ||
| 403 | (with-current-buffer ,buf | ||
| 404 | (vc-dir-refresh)))))) | ||
| 405 | ((derived-mode-p 'dired-mode) | ||
| 406 | (with-current-buffer process-buffer | ||
| 407 | (vc-exec-after | ||
| 408 | `(and (buffer-live-p ,buf) | ||
| 409 | (= (buffer-modified-tick ,buf) ,tick) | ||
| 410 | (with-current-buffer ,buf | ||
| 411 | (revert-buffer))))))))) | ||
| 386 | 412 | ||
| 387 | ;; These functions are used to ensure that the view the user sees is up to date | 413 | ;; These functions are used to ensure that the view the user sees is up to date |
| 388 | ;; even if the dispatcher client mode has messed with file contents (as in, | 414 | ;; even if the dispatcher client mode has messed with file contents (as in, |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index 592fc77e2e3..de729c969ae 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -607,9 +607,8 @@ The car of the list is the current branch." | |||
| 607 | 607 | ||
| 608 | (defun vc-git-pull (prompt) | 608 | (defun vc-git-pull (prompt) |
| 609 | "Pull changes into the current Git branch. | 609 | "Pull changes into the current Git branch. |
| 610 | Normally, this runs \"git pull\".If there is no default | 610 | Normally, this runs \"git pull\". If PROMPT is non-nil, prompt |
| 611 | location from which to pull or update, or if PROMPT is non-nil, | 611 | for the Git command to run." |
| 612 | prompt for the Git command to run." | ||
| 613 | (let* ((root (vc-git-root default-directory)) | 612 | (let* ((root (vc-git-root default-directory)) |
| 614 | (buffer (format "*vc-git : %s*" (expand-file-name root))) | 613 | (buffer (format "*vc-git : %s*" (expand-file-name root))) |
| 615 | (command "pull") | 614 | (command "pull") |
| @@ -618,14 +617,15 @@ prompt for the Git command to run." | |||
| 618 | ;; If necessary, prompt for the exact command. | 617 | ;; If necessary, prompt for the exact command. |
| 619 | (when prompt | 618 | (when prompt |
| 620 | (setq args (split-string | 619 | (setq args (split-string |
| 621 | (read-shell-command "Run Git (like this): " | 620 | (read-shell-command "Git pull command: " |
| 622 | "git pull" | 621 | "git pull" |
| 623 | 'vc-git-history) | 622 | 'vc-git-history) |
| 624 | " " t)) | 623 | " " t)) |
| 625 | (setq git-program (car args) | 624 | (setq git-program (car args) |
| 626 | command (cadr args) | 625 | command (cadr args) |
| 627 | args (cddr args))) | 626 | args (cddr args))) |
| 628 | (apply 'vc-do-async-command buffer root git-program command args))) | 627 | (apply 'vc-do-async-command buffer root git-program command args) |
| 628 | (vc-set-async-update buffer))) | ||
| 629 | 629 | ||
| 630 | (defun vc-git-merge-branch () | 630 | (defun vc-git-merge-branch () |
| 631 | "Merge changes into the current Git branch. | 631 | "Merge changes into the current Git branch. |
| @@ -634,9 +634,17 @@ This prompts for a branch to merge from." | |||
| 634 | (buffer (format "*vc-git : %s*" (expand-file-name root))) | 634 | (buffer (format "*vc-git : %s*" (expand-file-name root))) |
| 635 | (branches (cdr (vc-git-branches))) | 635 | (branches (cdr (vc-git-branches))) |
| 636 | (merge-source | 636 | (merge-source |
| 637 | (completing-read "Merge from branch: " branches nil t))) | 637 | (completing-read "Merge from branch: " |
| 638 | (if (or (member "FETCH_HEAD" branches) | ||
| 639 | (not (file-readable-p | ||
| 640 | (expand-file-name ".git/FETCH_HEAD" | ||
| 641 | root)))) | ||
| 642 | branches | ||
| 643 | (cons "FETCH_HEAD" branches)) | ||
| 644 | nil t))) | ||
| 638 | (apply 'vc-do-async-command buffer root "git" "merge" | 645 | (apply 'vc-do-async-command buffer root "git" "merge" |
| 639 | (list merge-source)))) | 646 | (list merge-source)) |
| 647 | (vc-set-async-update buffer))) | ||
| 640 | 648 | ||
| 641 | ;;; HISTORY FUNCTIONS | 649 | ;;; HISTORY FUNCTIONS |
| 642 | 650 | ||
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 8acff1ee2ca..7a0b8540ca3 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -610,8 +610,18 @@ REV is the revision to check out into WORKFILE." | |||
| 610 | (error "No log entries selected for push")))) | 610 | (error "No log entries selected for push")))) |
| 611 | 611 | ||
| 612 | (defun vc-hg-pull (prompt) | 612 | (defun vc-hg-pull (prompt) |
| 613 | "Issue a Mercurial pull command. | ||
| 614 | If called interactively with a set of marked Log View buffers, | ||
| 615 | call \"hg pull -r REVS\" to pull in the specified revisions REVS. | ||
| 616 | |||
| 617 | With a prefix argument or if PROMPT is non-nil, prompt for a | ||
| 618 | specific Mercurial pull command. The default is \"hg pull -u\", | ||
| 619 | which fetches changesets from the default remote repository and | ||
| 620 | then attempts to update the working directory." | ||
| 613 | (interactive "P") | 621 | (interactive "P") |
| 614 | (let (marked-list) | 622 | (let (marked-list) |
| 623 | ;; The `vc-hg-pull' command existed before the `pull' VC action | ||
| 624 | ;; was implemented. Keep it for backward compatibility. | ||
| 615 | (if (and (called-interactively-p 'interactive) | 625 | (if (and (called-interactively-p 'interactive) |
| 616 | (setq marked-list (log-view-get-marked))) | 626 | (setq marked-list (log-view-get-marked))) |
| 617 | (apply #'vc-hg-command | 627 | (apply #'vc-hg-command |
| @@ -624,26 +634,29 @@ REV is the revision to check out into WORKFILE." | |||
| 624 | (buffer (format "*vc-hg : %s*" (expand-file-name root))) | 634 | (buffer (format "*vc-hg : %s*" (expand-file-name root))) |
| 625 | (command "pull") | 635 | (command "pull") |
| 626 | (hg-program "hg") | 636 | (hg-program "hg") |
| 627 | ;; Todo: maybe check if we're up-to-date before updating | 637 | ;; Fixme: before updating the working copy to the latest |
| 628 | ;; the working copy to the latest state. | 638 | ;; state, should check if it's visiting an old revision. |
| 629 | (args '("-u"))) | 639 | (args '("-u"))) |
| 630 | ;; If necessary, prompt for the exact command. | 640 | ;; If necessary, prompt for the exact command. |
| 631 | (when prompt | 641 | (when prompt |
| 632 | (setq args (split-string | 642 | (setq args (split-string |
| 633 | (read-shell-command "Run Hg (like this): " "hg -u" | 643 | (read-shell-command "Run Hg (like this): " "hg pull -u" |
| 634 | 'vc-hg-history) | 644 | 'vc-hg-history) |
| 635 | " " t)) | 645 | " " t)) |
| 636 | (setq hg-program (car args) | 646 | (setq hg-program (car args) |
| 637 | command (cadr args) | 647 | command (cadr args) |
| 638 | args (cddr args))) | 648 | args (cddr args))) |
| 639 | (apply 'vc-do-async-command buffer root hg-program | 649 | (apply 'vc-do-async-command buffer root hg-program |
| 640 | command args))))) | 650 | command args) |
| 651 | (vc-set-async-update buffer))))) | ||
| 641 | 652 | ||
| 642 | (defun vc-hg-merge-branch () | 653 | (defun vc-hg-merge-branch () |
| 643 | "Merge incoming changes into the current Mercurial working directory." | 654 | "Merge incoming changes into the current working directory. |
| 655 | This runs the command \"hg merge\"." | ||
| 644 | (let* ((root (vc-hg-root default-directory)) | 656 | (let* ((root (vc-hg-root default-directory)) |
| 645 | (buffer (format "*vc-hg : %s*" (expand-file-name root)))) | 657 | (buffer (format "*vc-hg : %s*" (expand-file-name root)))) |
| 646 | (apply 'vc-do-async-command buffer root "hg" '("merge")))) | 658 | (apply 'vc-do-async-command buffer root "hg" '("merge")) |
| 659 | (vc-set-async-update buffer))) | ||
| 647 | 660 | ||
| 648 | ;;; Internal functions | 661 | ;;; Internal functions |
| 649 | 662 | ||