comparison lisp/vc-bzr.el @ 106387:e01e9655414f

Add support for bzr shelve/unshelve. * vc-bzr.el (vc-bzr-shelve-map, vc-bzr-shelve-menu-map) (vc-bzr-extra-menu-map): New variables. (vc-bzr-extra-menu, vc-bzr-extra-status-menu, vc-bzr-shelve) (vc-bzr-shelve-apply, vc-bzr-shelve-list) (vc-bzr-shelve-get-at-point, vc-bzr-shelve-delete-at-point) (vc-bzr-shelve-apply-at-point, vc-bzr-shelve-menu): New functions. (vc-bzr-dir-extra-headers): Display shelves.
author Dan Nicolaescu <dann@ics.uci.edu>
date Thu, 03 Dec 2009 07:46:13 +0000
parents d1166d927ca2
children afe271b2ef40
comparison
equal deleted inserted replaced
106386:d1166d927ca2 106387:e01e9655414f
702 "Return a list of conses (file . state) for DIR." 702 "Return a list of conses (file . state) for DIR."
703 (apply 'vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S" files) 703 (apply 'vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S" files)
704 (vc-exec-after 704 (vc-exec-after
705 `(vc-bzr-after-dir-status (quote ,update-function)))) 705 `(vc-bzr-after-dir-status (quote ,update-function))))
706 706
707 (defvar vc-bzr-shelve-map
708 (let ((map (make-sparse-keymap)))
709 ;; Turn off vc-dir marking
710 (define-key map [mouse-2] 'ignore)
711
712 (define-key map [down-mouse-3] 'vc-bzr-shelve-menu)
713 (define-key map "\C-k" 'vc-bzr-shelve-delete-at-point)
714 ;; (define-key map "=" 'vc-bzr-shelve-show-at-point)
715 ;; (define-key map "\C-m" 'vc-bzr-shelve-show-at-point)
716 (define-key map "A" 'vc-bzr-shelve-apply-at-point)
717 map))
718
719 (defvar vc-bzr-shelve-menu-map
720 (let ((map (make-sparse-keymap "Bzr Shelve")))
721 (define-key map [de]
722 '(menu-item "Delete shelf" vc-bzr-shelve-delete-at-point
723 :help "Delete the current shelf"))
724 (define-key map [ap]
725 '(menu-item "Apply shelf" vc-bzr-shelve-apply-at-point
726 :help "Apply the current shelf"))
727 ;; (define-key map [sh]
728 ;; '(menu-item "Show shelve" vc-bzr-shelve-show-at-point
729 ;; :help "Show the contents of the current shelve"))
730 map))
731
732 (defvar vc-bzr-extra-menu-map
733 (let ((map (make-sparse-keymap)))
734 (define-key map [bzr-sh]
735 '(menu-item "Shelve..." vc-bzr-shelve
736 :help "Shelve changes"))
737 map))
738
739 (defun vc-bzr-extra-menu () vc-bzr-extra-menu-map)
740
741 (defun vc-bzr-extra-status-menu () vc-bzr-extra-menu-map)
742
707 (defun vc-bzr-dir-extra-headers (dir) 743 (defun vc-bzr-dir-extra-headers (dir)
708 (let* 744 (let*
709 ((str (with-temp-buffer 745 ((str (with-temp-buffer
710 (vc-bzr-command "info" t 0 dir) 746 (vc-bzr-command "info" t 0 dir)
711 (buffer-string))) 747 (buffer-string)))
748 (shelve (vc-bzr-shelve-list))
749 (shelve-help-echo "Use M-x vc-bzr-shelve to create shelves")
712 (light-checkout 750 (light-checkout
713 (when (string-match ".+light checkout root: \\(.+\\)$" str) 751 (when (string-match ".+light checkout root: \\(.+\\)$" str)
714 (match-string 1 str))) 752 (match-string 1 str)))
715 (light-checkout-branch 753 (light-checkout-branch
716 (when light-checkout 754 (when light-checkout
732 (when light-checkout-branch 770 (when light-checkout-branch
733 (concat 771 (concat
734 (propertize "Checkout of branch : " 'face 'font-lock-type-face) 772 (propertize "Checkout of branch : " 'face 'font-lock-type-face)
735 (propertize light-checkout-branch 'face 'font-lock-variable-name-face) 773 (propertize light-checkout-branch 'face 'font-lock-variable-name-face)
736 "\n"))))) 774 "\n")))))
775 (if shelve
776 (concat
777 (propertize "Shelves :\n" 'face 'font-lock-type-face
778 'help-echo shelve-help-echo)
779 (mapconcat
780 (lambda (x)
781 (propertize x
782 'face 'font-lock-variable-name-face
783 'mouse-face 'highlight
784 'help-echo "mouse-3: Show shelve menu\nA: Apply shelf\nC-k: Delete shelf"
785 'keymap vc-bzr-shelve-map))
786 shelve "\n"))
787 (concat
788 (propertize "Shelves : " 'face 'font-lock-type-face
789 'help-echo shelve-help-echo)
790 (propertize "No shelved changes"
791 'help-echo shelve-help-echo
792 'face 'font-lock-variable-name-face))))))
793
794 (defun vc-bzr-shelve (name)
795 "Create a shelve."
796 (interactive "sShelf name: ")
797 (let ((root (vc-bzr-root default-directory)))
798 (when root
799 (vc-bzr-command "shelve" nil 0 nil "--all" "-m" name)
800 (vc-resynch-buffer root t t))))
801
802 ;; (defun vc-bzr-shelve-show (name)
803 ;; "Show the contents of shelve NAME."
804 ;; (interactive "sShelve name: ")
805 ;; (vc-setup-buffer "*vc-bzr-shelve*")
806 ;; ;; FIXME: how can you show the contents of a shelf?
807 ;; (vc-bzr-command "shelve" "*vc-bzr-shelve*" 'async nil name)
808 ;; (set-buffer "*vc-bzr-shelve*")
809 ;; (diff-mode)
810 ;; (setq buffer-read-only t)
811 ;; (pop-to-buffer (current-buffer)))
812
813 (defun vc-bzr-shelve-apply (name)
814 "Apply shelve NAME."
815 (interactive "sApply shelf: ")
816 (vc-bzr-command "unshelve" "*vc-bzr-shelve*" 0 nil "--apply" name)
817 (vc-resynch-buffer (vc-bzr-root default-directory) t t))
818
819 (defun vc-bzr-shelve-list ()
820 (with-temp-buffer
821 (vc-bzr-command "shelve" (current-buffer) 1 nil "--list" "-q")
822 (delete
823 ""
824 (split-string
825 (buffer-substring (point-min) (point-max))
826 "\n"))))
827
828 (defun vc-bzr-shelve-get-at-point (point)
829 (save-excursion
830 (goto-char point)
831 (beginning-of-line)
832 (if (looking-at "^ +\\([0-9]+\\):")
833 (match-string 1)
834 (error "Cannot find shelf at point"))))
835
836 (defun vc-bzr-shelve-delete-at-point ()
837 (interactive)
838 (let ((shelve (vc-bzr-shelve-get-at-point (point))))
839 (when (y-or-n-p (format "Remove shelf %s ?" shelve))
840 (vc-bzr-command "unshelve" nil 0 nil "--delete-only" shelve)
841 (vc-dir-refresh))))
842
843 ;; (defun vc-bzr-shelve-show-at-point ()
844 ;; (interactive)
845 ;; (vc-bzr-shelve-show (vc-bzr-shelve-get-at-point (point))))
846
847 (defun vc-bzr-shelve-apply-at-point ()
848 (interactive)
849 (vc-bzr-shelve-apply (vc-bzr-shelve-get-at-point (point))))
850
851 (defun vc-bzr-shelve-menu (e)
852 (interactive "e")
853 (vc-dir-at-event e (popup-menu vc-bzr-shelve-menu-map e)))
737 854
738 ;;; Revision completion 855 ;;; Revision completion
739 856
740 (eval-and-compile 857 (eval-and-compile
741 (defconst vc-bzr-revision-keywords 858 (defconst vc-bzr-revision-keywords