Subject: bug#25710: Acknowledgement (25.1.91; vc-retrieve-tag does not offer branch namd completion)

From: Dmitry Gutov <[email-masked]>
Date: Fri, 17 Feb 2017 03:26:37 +0200

On 15.02.2017 06:35, Tom Tromey wrote:

> Emacs itself has 144 tags, while I have about 16 branches.
> So for me at least, for this project, that's 90% clutter and 10% things
> I might actually want to complete.

All Emacs tags start with "emacs-", so if you just input any other 
character and press TAB, you won't see the tags.

> For my gdb checkout I have 32 branches and there are 636 tags, so the
> ratio is even worse there -- about 5% useful things.

I think we should consider whether it's likely to be a problem, and not 
just reject the unlikely options. Because other people's workflows can 
be different.

And I do anticipate having to check out a particular release version, 
someday.

Further, like Artem reminded us, we already have a revisions completion 
table. So the attached patch seems preferable to me. WDYT?
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index c308856..358f36a 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2163,18 +2163,22 @@ vc-retrieve-tag
 locked files at or below DIR (but if NAME is empty, locked files are
 allowed and simply skipped)."
   (interactive
-   (let ((granularity
-	  (vc-call-backend (vc-responsible-backend default-directory)
-			   'revision-granularity)))
+   (let* ((granularity
+           (vc-call-backend (vc-responsible-backend default-directory)
+                            'revision-granularity))
+          (dir
+           (if (eq granularity 'repository)
+               ;; For VC's that do not work at file level, it's pointless
+               ;; to ask for a directory, branches are created at repository level.
+               ;; XXX: Either we call expand-file-name here, or use
+               ;; file-in-directory-p inside vc-resynch-buffers-in-directory.
+               (expand-file-name (vc-root-dir))
+             (read-directory-name "Directory: " default-directory nil t))))
      (list
-      (if (eq granularity 'repository)
-	  ;; For VC's that do not work at file level, it's pointless
-	  ;; to ask for a directory, branches are created at repository level.
-          ;; XXX: Either we call expand-file-name here, or use
-          ;; file-in-directory-p inside vc-resynch-buffers-in-directory.
-	  (expand-file-name (vc-root-dir))
-	(read-directory-name "Directory: " default-directory default-directory t))
-      (read-string "Tag name to retrieve (default latest revisions): "))))
+      dir
+      (vc-read-revision "Tag name to retrieve (default latest revisions): "
+                        (list dir)
+                        (vc-responsible-backend dir)))))
   (let ((update (yes-or-no-p "Update any affected buffers? "))
 	(msg (if (or (not name) (string= name ""))
 		 (format "Updating %s... " (abbreviate-file-name dir))