emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/vc-got 5fb2f47 099/145: implement revision-completion-t


From: ELPA Syncer
Subject: [elpa] externals/vc-got 5fb2f47 099/145: implement revision-completion-table
Date: Thu, 9 Sep 2021 15:58:42 -0400 (EDT)

branch: externals/vc-got
commit 5fb2f47455079158990731f00c405d0fa88788a6
Author: Omar Polo <op@omarpolo.com>
Commit: Omar Polo <op@omarpolo.com>

    implement revision-completion-table
---
 vc-got.el | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/vc-got.el b/vc-got.el
index 92b9a8c..64c938c 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -78,7 +78,7 @@
 ;; - comment-history                    NOT IMPLEMENTED
 ;; - update-changelog                   NOT IMPLEMENTED
 ;; * diff                               DONE
-;; - revision-completion-table          NOT IMPLEMENTED
+;; - revision-completion-table          DONE
 ;; - annotate-command                   DONE
 ;; - annotate-time                      DONE
 ;; - annotate-current-time              NOT IMPLEMENTED
@@ -374,6 +374,21 @@ files on disk."
                            (when keep-local "-k")
                            file)))))
 
+(defun vc-got--ref ()
+  "Return a list of all references."
+  (let (process-file-side-effects
+        (re "^refs/\\(heads\\|remotes\\|tags\\)/\\(.*\\):")
+        ;; hardcoding HEAD because it's always present and the regexp
+        ;; won't match it.
+        (table (list "HEAD")))
+    (vc-got-with-worktree default-directory
+      (with-temp-buffer
+        (when (zerop (vc-got--call "ref" "-l"))
+          (goto-char (point-min))
+          (while (re-search-forward re nil t)
+            (push (match-string 2) table))
+          table)))))
+
 
 ;; Backend properties
 
@@ -708,6 +723,14 @@ Heavily inspired by `vc-git-log-view-mode'."
           ;; (i.e. get the patch from `got log -p rev1')
           (vc-got--diff rev1 rev2))))))
 
+(defun vc-got-revision-completion-table (_files)
+  "Return a completion table for existing revisions.
+Ignores FILES because GoT doesn't have the concept of ``file
+revisions''; instead, like with git, you have tags and branches."
+  (letrec ((table (lazy-completion-table
+                   table (lambda () (vc-got--ref)))))
+    table))
+
 (defun vc-got-annotate-command (file buf &optional rev)
   "Show annotated contents of FILE in buffer BUF.  If given, use revision REV."
   (let (process-file-side-effects)



reply via email to

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