aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Nicolaescu2009-12-03 04:08:08 +0000
committerDan Nicolaescu2009-12-03 04:08:08 +0000
commit7fa4876f18cdbd6a70898835df8c01615801c2fa (patch)
tree7579cfcc60b41820534fff65f1fc9b189404eb08
parentd6e824528b1c20bcd61f2d35539e399343575b44 (diff)
downloademacs-7fa4876f18cdbd6a70898835df8c01615801c2fa.tar.gz
emacs-7fa4876f18cdbd6a70898835df8c01615801c2fa.zip
Support applying stashes. Improve UI.
* vc-git.el (vc-git-dir-extra-headers): Add tooltips. (vc-git-stash-apply, vc-git-stash-pop) (vc-git-stash-apply-at-point, vc-git-stash-pop-at-point) (vc-git-stash-menu): New functions. (vc-git-stash-menu-map): New variable. (vc-git-stash-map): Add bindings to popup a menu and to apply stashes.
-rw-r--r--etc/NEWS2
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/vc-git.el55
3 files changed, 64 insertions, 3 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 367c2fe0728..fbf7f3d6f6b 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -264,7 +264,7 @@ advantage of this feature.
264Signed-off-by line when committing. 264Signed-off-by line when committing.
265 265
266**** Support for operating with stashes has been added to vc-dir: the stash list is 266**** Support for operating with stashes has been added to vc-dir: the stash list is
267displayed in the *vc-dir* header, stashes can be created, removed and 267displayed in the *vc-dir* header, stashes can be created, removed, applied and
268their content displayed. 268their content displayed.
269 269
270**** vc-dir displays the stash status 270**** vc-dir displays the stash status
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index d4363f14c0f..dd43a497686 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12009-12-03 Dan Nicolaescu <dann@ics.uci.edu>
2
3 Support applying stashes. Improve UI.
4 * vc-git.el (vc-git-dir-extra-headers): Add tooltips.
5 (vc-git-stash-apply, vc-git-stash-pop)
6 (vc-git-stash-apply-at-point, vc-git-stash-pop-at-point)
7 (vc-git-stash-menu): New functions.
8 (vc-git-stash-menu-map): New variable.
9 (vc-git-stash-map): Add bindings to popup a menu and to apply stashes.
10
12009-12-03 Glenn Morris <rgm@gnu.org> 112009-12-03 Glenn Morris <rgm@gnu.org>
2 12
3 * vc.el (log-view-vc-backend, log-view-vc-fileset): Declare. 13 * vc.el (log-view-vc-backend, log-view-vc-fileset): Declare.
diff --git a/lisp/vc-git.el b/lisp/vc-git.el
index a4e01e8d8c5..a33a0f51d7d 100644
--- a/lisp/vc-git.el
+++ b/lisp/vc-git.el
@@ -405,9 +405,31 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
405 405
406(defvar vc-git-stash-map 406(defvar vc-git-stash-map
407 (let ((map (make-sparse-keymap))) 407 (let ((map (make-sparse-keymap)))
408 ;; Turn off vc-dir marking
409 (define-key map [mouse-2] 'ignore)
410
411 (define-key map [down-mouse-3] 'vc-git-stash-menu)
408 (define-key map "\C-k" 'vc-git-stash-delete-at-point) 412 (define-key map "\C-k" 'vc-git-stash-delete-at-point)
409 (define-key map "=" 'vc-git-stash-show-at-point) 413 (define-key map "=" 'vc-git-stash-show-at-point)
410 (define-key map "\C-m" 'vc-git-stash-show-at-point) 414 (define-key map "\C-m" 'vc-git-stash-show-at-point)
415 (define-key map "A" 'vc-git-stash-apply-at-point)
416 (define-key map "P" 'vc-git-stash-pop-at-point)
417 map))
418
419(defvar vc-git-stash-menu-map
420 (let ((map (make-sparse-keymap "Git Stash")))
421 (define-key map [de]
422 '(menu-item "Delete stash" vc-git-stash-delete-at-point
423 :help "Delete the current stash"))
424 (define-key map [ap]
425 '(menu-item "Apply stash" vc-git-stash-apply-at-point
426 :help "Apply the current stash and keep it in the stash list"))
427 (define-key map [po]
428 '(menu-item "Apply and remove stash (pop)" vc-git-stash-pop-at-point
429 :help "Apply the current stash and remove it"))
430 (define-key map [sh]
431 '(menu-item "Show stash" vc-git-stash-show-at-point
432 :help "Show the contents of the current stash"))
411 map)) 433 map))
412 434
413(defun vc-git-dir-extra-headers (dir) 435(defun vc-git-dir-extra-headers (dir)
@@ -415,6 +437,7 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
415 (with-current-buffer standard-output 437 (with-current-buffer standard-output
416 (vc-git--out-ok "symbolic-ref" "HEAD")))) 438 (vc-git--out-ok "symbolic-ref" "HEAD"))))
417 (stash (vc-git-stash-list)) 439 (stash (vc-git-stash-list))
440 (stash-help-echo "Use M-x vc-git-stash to create stashes.")
418 branch remote remote-url) 441 branch remote remote-url)
419 (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str) 442 (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
420 (progn 443 (progn
@@ -447,17 +470,21 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
447 "\n" 470 "\n"
448 (if stash 471 (if stash
449 (concat 472 (concat
450 (propertize "Stash :\n" 'face 'font-lock-type-face) 473 (propertize "Stash :\n" 'face 'font-lock-type-face
474 'help-echo stash-help-echo)
451 (mapconcat 475 (mapconcat
452 (lambda (x) 476 (lambda (x)
453 (propertize x 477 (propertize x
454 'face 'font-lock-variable-name-face 478 'face 'font-lock-variable-name-face
455 'mouse-face 'highlight 479 'mouse-face 'highlight
480 'help-echo "mouse-3: Show stash menu\nRET: Show stash\nA: Apply stash\nP: Apply and remove stash (pop)\nC-k: Delete stash"
456 'keymap vc-git-stash-map)) 481 'keymap vc-git-stash-map))
457 stash "\n")) 482 stash "\n"))
458 (concat 483 (concat
459 (propertize "Stash : " 'face 'font-lock-type-face) 484 (propertize "Stash : " 'face 'font-lock-type-face
485 'help-echo stash-help-echo)
460 (propertize "Nothing stashed" 486 (propertize "Nothing stashed"
487 'help-echo stash-help-echo
461 'face 'font-lock-variable-name-face)))))) 488 'face 'font-lock-variable-name-face))))))
462 489
463;;; STATE-CHANGING FUNCTIONS 490;;; STATE-CHANGING FUNCTIONS
@@ -816,6 +843,18 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
816 (setq buffer-read-only t) 843 (setq buffer-read-only t)
817 (pop-to-buffer (current-buffer))) 844 (pop-to-buffer (current-buffer)))
818 845
846(defun vc-git-stash-apply (name)
847 "Apply stash NAME."
848 (interactive "sApply stash: ")
849 (vc-git-command "*vc-git-stash*" 0 nil "stash" "apply" "-q" name)
850 (vc-resynch-buffer (vc-git-root default-directory) t t))
851
852(defun vc-git-stash-pop (name)
853 "Pop stash NAME."
854 (interactive "sPop stash: ")
855 (vc-git-command "*vc-git-stash*" 0 nil "stash" "pop" "-q" name)
856 (vc-resynch-buffer (vc-git-root default-directory) t t))
857
819(defun vc-git-stash-list () 858(defun vc-git-stash-list ()
820 (delete 859 (delete
821 "" 860 ""
@@ -843,6 +882,18 @@ This command shares argument histories with \\[rgrep] and \\[grep]."
843 (interactive) 882 (interactive)
844 (vc-git-stash-show (format "stash@%s" (vc-git-stash-get-at-point (point))))) 883 (vc-git-stash-show (format "stash@%s" (vc-git-stash-get-at-point (point)))))
845 884
885(defun vc-git-stash-apply-at-point ()
886 (interactive)
887 (vc-git-stash-apply (format "stash@%s" (vc-git-stash-get-at-point (point)))))
888
889(defun vc-git-stash-pop-at-point ()
890 (interactive)
891 (vc-git-stash-pop (format "stash@%s" (vc-git-stash-get-at-point (point)))))
892
893(defun vc-git-stash-menu (e)
894 (interactive "e")
895 (vc-dir-at-event e (popup-menu vc-git-stash-menu-map e)))
896
846 897
847;;; Internal commands 898;;; Internal commands
848 899