bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25710: Acknowledgement (25.1.91; vc-retrieve-tag does not offer bran


From: Tom Tromey
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
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.91 (gnu/linux)

This patch seems to work for me.

Tom

commit ead2e9319b5676d2c637474d12d1c4d10fe7167f
Author: Tom Tromey <address@hidden>
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))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]