unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Tom Tromey <tom@tromey.com>
To: 25710@debbugs.gnu.org
Subject: bug#25710: Acknowledgement (25.1.91; vc-retrieve-tag does not offer branch namd completion)
Date: Mon, 13 Feb 2017 20:13:14 -0700	[thread overview]
Message-ID: <87r331zcqd.fsf@tromey.com> (raw)
In-Reply-To: <handler.25710.B.148702752518881.ack@debbugs.gnu.org> (GNU bug Tracking System's message of "Mon, 13 Feb 2017 23:13:02 +0000")

This patch seems to work for me.

Tom

commit ead2e9319b5676d2c637474d12d1c4d10fe7167f
Author: Tom Tromey <tom@tromey.com>
Date:   Mon Feb 13 20:11:14 2017 -0700

    Add completion for branch switches in git
    
    Bug#25710
    * lisp/vc/vc-git.el (vc-git-list-branches): New function.
    * lisp/vc/vc.el (vc-retrieve-tag-history): New global.
    (vc-retrieve-tag): Call 'list-branches.  Use vc-retrieve-tag-history.
    (vc-default-list-branches): New function.

diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 8a22d74..0c11a7f 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -1242,6 +1242,9 @@ vc-git-retrieve-tag
   (let ((default-directory dir))
     (vc-git-command nil 0 nil "checkout" name)))
 
+(defun vc-git-list-branches (dir)
+  (let ((default-directory dir))
+    (vc-git-branches)))
 
 ;;; MISCELLANEOUS
 
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index c66a092..72151c0 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -450,6 +450,12 @@
 ;;   does a sanity check whether there aren't any uncommitted changes at
 ;;   or below DIR, and then performs a tree walk, using the `checkout'
 ;;   function to retrieve the corresponding revisions.
+;;
+;; - list-branches (dir)
+;;
+;;   Return a list of strings, each of which names a branch that can
+;;   be switched to with `vc-git-retrieve-tag'.  The default
+;;   implementation returns nil.
 
 ;; MISCELLANEOUS
 ;;
@@ -2151,6 +2157,9 @@ vc-create-tag
   (vc-resynch-buffer dir t t t)
   (message "Making %s... done" (if branchp "branch" "tag")))
 
+(defvar vc-retrieve-tag-history nil
+  "History for `vc-retrieve-tag'.")
+
 ;;;###autoload
 (defun vc-retrieve-tag (dir name)
   "For each file in or below DIR, retrieve their tagged version NAME.
@@ -2172,7 +2181,11 @@ vc-retrieve-tag
 	  ;; to ask for a directory, branches are created at repository level.
 	  default-directory
 	(read-directory-name "Directory: " default-directory default-directory t))
-      (read-string "Tag name to retrieve (default latest revisions): "))))
+      (completing-read "Tag name to retrieve (default latest revisions): "
+                       (vc-call-backend (vc-responsible-backend
+                                         default-directory)
+                                        'list-branches default-directory)
+                       nil nil nil 'vc-retrieve-tag-history))))
   (let ((update (yes-or-no-p "Update any affected buffers? "))
 	(msg (if (or (not name) (string= name ""))
 		 (format "Updating %s... " (abbreviate-file-name dir))
@@ -2853,6 +2866,12 @@ vc-default-retrieve-tag
 		 (vc-call-backend backend 'checkout f nil name)
 		 (when update (vc-resynch-buffer f t t)))))))))
 
+(defun vc-default-list-branches (backend dir)
+  "Default implementation of 'list-branches function.
+This function should return a list of possible branches to switch to.
+The default implementation returns nil."
+  nil)
+
 (defun vc-default-revert (backend file contents-done)
   (unless contents-done
     (let ((rev (vc-working-revision file))





  parent reply	other threads:[~2017-02-14  3:13 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13 23:11 bug#25710: 25.1.91; vc-retrieve-tag does not offer branch namd completion Tom Tromey
     [not found] ` <handler.25710.B.148702752518881.ack@debbugs.gnu.org>
2017-02-14  3:13   ` Tom Tromey [this message]
2017-02-14 10:24     ` bug#25710: Acknowledgement (25.1.91; vc-retrieve-tag does not offer branch namd completion) Dmitry Gutov
     [not found]       ` <87inoczdun.fsf@tromey.com>
2017-02-14 23:31         ` Dmitry Gutov
2017-02-15  4:35           ` Tom Tromey
2017-02-17  1:26             ` Dmitry Gutov
2017-02-17  4:09               ` Tom Tromey
2017-02-19 22:13                 ` Dmitry Gutov
2017-03-04 18:06                   ` Tom Tromey
2017-03-06 11:42                     ` Dmitry Gutov
2020-08-11  7:56                       ` Stefan Kangas
2020-08-11 19:44                         ` Dmitry Gutov
2020-08-19 11:39                           ` Lars Ingebrigtsen
2017-02-16  3:38 ` bug#25710: Branch completion on vc-retrive-tag Artem Malyshev

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87r331zcqd.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=25710@debbugs.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).