From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: support for bzr shelve/unshelve in vc-dir Date: Tue, 1 Dec 2009 21:43:20 -0800 (PST) Message-ID: <200912020543.nB25hKYW002114@godzilla.ics.uci.edu> References: <200912011947.nB1JlaAp027561@godzilla.ics.uci.edu> <200912012048.nB1Kmjwd025538@fed.local> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1259732812 27537 80.91.229.12 (2 Dec 2009 05:46:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Dec 2009 05:46:52 +0000 (UTC) Cc: emacs-devel@gnu.org To: Xavier Maillard Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Dec 02 06:46:44 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NFi30-00045r-FW for ged-emacs-devel@m.gmane.org; Wed, 02 Dec 2009 06:46:44 +0100 Original-Received: from localhost ([127.0.0.1]:57466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFi30-0000yn-1I for ged-emacs-devel@m.gmane.org; Wed, 02 Dec 2009 00:46:42 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFi2u-0000xd-CE for emacs-devel@gnu.org; Wed, 02 Dec 2009 00:46:36 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFi2p-0000rj-0c for emacs-devel@gnu.org; Wed, 02 Dec 2009 00:46:35 -0500 Original-Received: from [199.232.76.173] (port=35187 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFi2o-0000rT-QS for emacs-devel@gnu.org; Wed, 02 Dec 2009 00:46:30 -0500 Original-Received: from colin-baker-v0.ics.uci.edu ([128.195.1.153]:37216) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NFi2l-0002Ti-KD; Wed, 02 Dec 2009 00:46:28 -0500 Original-Received: from godzilla.ics.uci.edu (godzilla.ics.uci.edu [128.195.10.101]) by colin-baker-v0.ics.uci.edu (8.13.8/8.13.8) with ESMTP id nB25hLjl019472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 1 Dec 2009 21:43:21 -0800 Original-Received: (from dann@localhost) by godzilla.ics.uci.edu (8.13.8+Sun/8.13.6/Submit) id nB25hKYW002114; Tue, 1 Dec 2009 21:43:20 -0800 (PST) In-Reply-To: <200912012048.nB1Kmjwd025538@fed.local> (Xavier Maillard's message of "Tue, 1 Dec 2009 21:48:45 +0100") Original-Lines: 150 X-ICS-MailScanner-Information: Please send mail to helpdesk@ics.uci.edu or more information X-ICS-MailScanner-ID: nB25hLjl019472 X-ICS-MailScanner: Found to be clean X-ICS-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-0.263, required 5, autolearn=disabled, ALL_TRUSTED -1.44, FM_MULTI_ODD2 1.10, TW_BZ 0.08) X-ICS-MailScanner-From: dann@godzilla.ics.uci.edu X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:118117 Archived-At: Xavier Maillard writes: > Are the bzr shelve/unshelve commands popular? > > Do we want something similar to the vc-dir support for "git stash" for > bzr shelve/unshelve? > > If yes, I can try to whip up a patch before the feature freeze... > > Speaking for myself, I'd vote for this feature. Here's a quick port of the git code (It still uses the "stash" name). It can create and remove shelves. I don't see a way to display the diff for a shelf. Index: vc-bzr.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/vc-bzr.el,v retrieving revision 1.86 diff -u -3 -p -u -p -r1.86 vc-bzr.el --- vc-bzr.el 26 Nov 2009 14:50:32 -0000 1.86 +++ vc-bzr.el 2 Dec 2009 05:25:45 -0000 @@ -703,11 +705,33 @@ stream. Standard error output is discar (vc-exec-after `(vc-bzr-after-dir-status (quote ,update-function)))) +(defvar vc-bzr-stash-map + (let ((map (make-sparse-keymap))) + (define-key map "\C-k" 'vc-bzr-stash-delete-at-point) + (define-key map "=" 'vc-bzr-stash-show-at-point) + (define-key map "\C-m" 'vc-bzr-stash-show-at-point) + map)) + +(defvar vc-bzr-extra-menu-map + (let ((map (make-sparse-keymap))) + (define-key map [bzr-st] + '(menu-item "Stash..." vc-bzr-stash + :help "Stash away changes")) + (define-key map [bzr-ss] + '(menu-item "Show Stash..." vc-bzr-stash-show + :help "Show stash contents")) + map)) + +(defun vc-bzr-extra-menu () vc-bzr-extra-menu-map) + +(defun vc-bzr-extra-status-menu () vc-bzr-extra-menu-map) + (defun vc-bzr-dir-extra-headers (dir) (let* ((str (with-temp-buffer (vc-bzr-command "info" t 0 dir) (buffer-string))) + (stash (vc-bzr-stash-list)) (light-checkout (when (string-match ".+light checkout root: \\(.+\\)$" str) (match-string 1 str))) @@ -721,18 +745,81 @@ stream. Standard error output is discar (if (string-match "parent branch: \\(.+\\)$" str) (match-string 1 str) "None") - 'face 'font-lock-variable-name-face) + 'face 'font-lock-variable-name-face) "\n" - (when light-checkout - (concat - (propertize "Light checkout root: " 'face 'font-lock-type-face) - (propertize light-checkout 'face 'font-lock-variable-name-face) - "\n")) - (when light-checkout-branch - (concat - (propertize "Checkout of branch : " 'face 'font-lock-type-face) - (propertize light-checkout-branch 'face 'font-lock-variable-name-face) - "\n"))))) + (when light-checkout + (concat + (propertize "Light checkout root: " 'face 'font-lock-type-face) + (propertize light-checkout 'face 'font-lock-variable-name-face) + "\n")) + (when light-checkout-branch + (concat + (propertize "Checkout of branch : " 'face 'font-lock-type-face) + (propertize light-checkout-branch 'face 'font-lock-variable-name-face) + "\n")) + (if stash + (concat + (propertize "Stash :\n" 'face 'font-lock-type-face) + (mapconcat + (lambda (x) + (propertize x + 'face 'font-lock-variable-name-face + 'mouse-face 'highlight + 'keymap vc-bzr-stash-map)) + stash "\n")) + (concat + (propertize "Stash : " 'face 'font-lock-type-face) + (propertize "Nothing stashed" + 'face 'font-lock-variable-name-face)))))) + + +(defun vc-bzr-stash (name) + "Create a stash." + (interactive "sStash name: ") + (let ((root (vc-bzr-root default-directory))) + (when root + (vc-bzr-command "shelve" nil 0 nil "--all" "-m" name) + (vc-resynch-buffer root t t)))) + +(defun vc-bzr-stash-show (name) + "Show the contents of stash NAME." + (interactive "sStash name: ") + (vc-setup-buffer "*vc-bzr-stash*") + ;; FIXME: how can you show the contents of a shelf? + (vc-bzr-command "shelve" "*vc-bzr-stash*" 'async nil name) + (set-buffer "*vc-bzr-stash*") + (diff-mode) + (setq buffer-read-only t) + (pop-to-buffer (current-buffer))) + +(defun vc-bzr-stash-list () + (with-temp-buffer + (vc-bzr-command "shelve" (current-buffer) 1 nil "--list") + (delete + "" + (split-string + (buffer-substring (point-min) (point-max)) + "\n")))) + +(defun vc-bzr-stash-get-at-point (point) + (save-excursion + (goto-char point) + (beginning-of-line) + (if (looking-at "^ +\\([0-9]+\\):") + (match-string 1) + (error "Cannot find stash at point")))) + +(defun vc-bzr-stash-delete-at-point () + (interactive) + (let ((stash (vc-bzr-stash-get-at-point (point)))) + (when (y-or-n-p (format "Remove stash %s ?" stash)) + (vc-bzr-command "unshelve" nil 0 nil "--delete-only" stash) + (vc-dir-refresh)))) + +(defun vc-bzr-stash-show-at-point () + (interactive) + (vc-bzr-stash-show (vc-bzr-stash-get-at-point (point)))) + ;;; Revision completion