all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Nicolaescu <dann@ics.uci.edu>
To: Xavier Maillard <xma@gnu.org>
Cc: emacs-devel@gnu.org
Subject: Re: support for bzr shelve/unshelve in vc-dir
Date: Tue, 1 Dec 2009 21:43:20 -0800 (PST)	[thread overview]
Message-ID: <200912020543.nB25hKYW002114@godzilla.ics.uci.edu> (raw)
In-Reply-To: <200912012048.nB1Kmjwd025538@fed.local> (Xavier Maillard's message of "Tue, 1 Dec 2009 21:48:45 +0100")

Xavier Maillard <xma@gnu.org> 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
 




  reply	other threads:[~2009-12-02  5:43 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-01 19:47 support for bzr shelve/unshelve in vc-dir Dan Nicolaescu
2009-12-01 20:48 ` Xavier Maillard
2009-12-02  5:43   ` Dan Nicolaescu [this message]
2009-12-02  6:37     ` Óscar Fuentes
2009-12-01 22:11 ` Stefan Monnier
2009-12-01 22:50   ` Óscar Fuentes
2009-12-01 23:18     ` Óscar Fuentes
2009-12-02  3:00       ` Dan Nicolaescu
2009-12-02  3:03   ` Dan Nicolaescu
2009-12-02  3:31     ` Óscar Fuentes
2009-12-02  4:35       ` Stefan Monnier
2009-12-02  5:06         ` Óscar Fuentes
2009-12-02  6:16         ` Stephen J. Turnbull
2009-12-02  6:42           ` Óscar Fuentes
2009-12-03  7:48   ` Dan Nicolaescu
2009-12-03  8:25     ` Óscar Fuentes
2009-12-03  8:32       ` Bojan Nikolic
2009-12-03  9:07       ` Dan Nicolaescu
2009-12-03 17:05         ` Splitting changes (was: support for bzr shelve/unshelve in vc-dir) Stefan Monnier
2009-12-03 17:46           ` Eli Zaretskii
2009-12-03 19:26             ` Splitting changes Stefan Monnier
2009-12-03 19:47           ` Óscar Fuentes
2009-12-03 20:50             ` Stefan Monnier
2009-12-03 17:24         ` support for bzr shelve/unshelve in vc-dir Óscar Fuentes
2009-12-03 18:18           ` Óscar Fuentes
2009-12-03 18:48             ` Dan Nicolaescu
2009-12-03 19:00               ` Óscar Fuentes
2009-12-03 19:17                 ` Dan Nicolaescu
2009-12-03 21:30                   ` Óscar Fuentes
2009-12-03 22:57                     ` Dan Nicolaescu
2009-12-04  0:42                       ` Stephen J. Turnbull
2009-12-04  1:47                         ` Dan Nicolaescu
2009-12-04  2:57                           ` Óscar Fuentes
2009-12-04  6:36                             ` Stephen J. Turnbull
2009-12-04 21:18                             ` Dan Nicolaescu
2009-12-04 21:59                               ` Óscar Fuentes
2009-12-04 22:57                                 ` Dan Nicolaescu
2009-12-04 23:52                                 ` Glenn Morris
2009-12-05  3:57                                   ` Stephen J. Turnbull
2009-12-05  6:49                                     ` Jan Djärv
2009-12-05  7:12                                       ` Miles Bader
2009-12-05 16:12                                         ` Stefan Monnier
2009-12-05 12:09                                       ` Stephen J. Turnbull
2009-12-05 19:59                                   ` Glenn Morris
2009-12-06 19:27                                   ` Richard Stallman
2009-12-06 20:11                                     ` GNU bzr [was Re: support for bzr shelve/unshelve in vc-dir] Glenn Morris
2009-12-09 13:20                                       ` Richard Stallman
2009-12-09 16:50                                         ` GNU bzr Karl Fogel
2009-12-15 23:11                                           ` Karl Fogel
2009-12-10  0:16                                   ` support for bzr shelve/unshelve in vc-dir Martin Pool
2009-12-10  3:46                                     ` Stefan Monnier
2009-12-10  4:19                                       ` Martin Pool
2009-12-10 14:02                                     ` Dan Nicolaescu
2009-12-11  4:02                                       ` Martin Pool
2009-12-18 15:39                                         ` Dan Nicolaescu
2009-12-21  1:49                                           ` Martin Pool
2009-12-11  5:53                                       ` Martin Pool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200912020543.nB25hKYW002114@godzilla.ics.uci.edu \
    --to=dann@ics.uci.edu \
    --cc=emacs-devel@gnu.org \
    --cc=xma@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.