[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/vc-got 23a0b46 002/145: implemented some state-changing
From: |
ELPA Syncer |
Subject: |
[elpa] externals/vc-got 23a0b46 002/145: implemented some state-changing functions |
Date: |
Thu, 9 Sep 2021 15:58:21 -0400 (EDT) |
branch: externals/vc-got
commit 23a0b465c39b4a1717ef71fc45bb57d7edca358e
Author: Omar Polo <op@omarpolo.com>
Commit: Omar Polo <op@omarpolo.com>
implemented some state-changing functions
vc-got-create-repo is un-implemented: should we run got init?
---
vc-got.el | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 77 insertions(+), 2 deletions(-)
diff --git a/vc-got.el b/vc-got.el
index 89c6e9b..ab672dc 100644
--- a/vc-got.el
+++ b/vc-got.el
@@ -46,6 +46,19 @@
;; * working-revision DONE
;; * checkout-model DONE
;; - mode-line-string NOT IMPLEMENTED
+;;
+;; STATE-CHANGING FUNCTIONS:
+;; * create-repo NOT IMPLEMENTED
+;; I don't think got init does
+;; what this function is supposed
+;; to do.
+;; * register DONE
+;; - responsible-p DONE
+;; - receive-file NOT IMPLEMENTED
+;; - unregister NOT IMPLEMENTED
+;; use remove?
+;; * checkin DONE
+;; * find-revision DONE
;; TODO: use the idiom
;; (let (process-file-side-effects) ...)
@@ -59,6 +72,7 @@
(require 'cl-lib)
(require 'seq)
+(require 'vc)
(defvar vc-got-cmd "got"
"The got command.")
@@ -80,10 +94,20 @@
"Call `vc-got-cmd' in the `default-directory' with ARGS and put the output
in the current buffer."
(apply #'process-file vc-got-cmd nil (current-buffer) nil args))
+(defun vc-got--add (files)
+ "Add FILES to got, passing `vc-register-switches' to the command invocation."
+ (with-temp-buffer
+ (apply #'vc-got--call "add" (append vc-register-switches files))))
+
(defun vc-got--log (limit path)
- "Execute the log command in the worktree of PATH, with LIMIT commits, and
put the output in the current buffer.
+ "Execute the log command in the worktree of PATH.
+
+The output of the command will be put in the current-buffer.
+
+LIMIT limits the maximum number of commit returned.
-Return nil if the command failed or if PATH isn't included in any worktree."
+Return nil if the command failed or if PATH isn't included in any
+worktree."
(vc-got-with-worktree path
(zerop (vc-got--call "log" "-l" (format "%s" limit) path))))
@@ -125,6 +149,33 @@ DIR-OR-FILE."
collect (cl-destructuring-bind (status file) (split-string line " "
t " ")
`(,file . ,(vc-got--parse-status-flag status)))))
+(defun vc-got--tree-parse ()
+ "Parse into an alist the output of got tree -i in the current buffer."
+ (goto-char (point-min))
+ (cl-loop
+ until (= (point) (point-max))
+ collect (let* ((obj-start (point))
+ (_ (forward-word))
+ (obj (buffer-substring obj-start (point)))
+ (_ (forward-char)) ;skip the space
+ (filename-start (point))
+ (_ (move-end-of-line nil))
+ (filename (buffer-substring filename-start (point))))
+ ;; goto the start of the next line
+ (forward-line)
+ (move-beginning-of-line nil)
+ `(,filename . ,obj))))
+
+(defun vc-got--tree (commit path)
+ (vc-got-with-worktree path
+ (with-temp-buffer
+ (vc-got--call "tree" "-c" commit "-i" path)
+ (vc-got--tree-parse))))
+
+(defun vc-got--cat (commit obj-id)
+ "Execute got cat -c COMMIT OBJ-ID in the current buffer."
+ (vc-got--call "cat" "-c" commit obj-id))
+
;; Backend properties
@@ -224,5 +275,29 @@ Return \"0\" for a file added but not yet committed."
(defun vc-got-checkout-model (_files)
'implicit)
+
+;; state-changing functions
+
+(defun vc-got-create-repo (_backend)
+ (error "vc got: create-repo not implemented"))
+
+(defun vc-got-register (files &optional _comment)
+ "Register FILES, passing `vc-register-switches' to the backend command."
+ (vc-got--add files))
+
+(defun vc-got-responsible-p (file)
+ (vc-find-root file ".got"))
+
+(defun vc-got-checkin (files comment &optional _rev)
+ "Commit FILES with COMMENT as commit message."
+ (with-temp-buffer
+ (apply #'vc-got--call "commit" "-m" comment files)))
+
+(defun vc-got-find-revision (file rev buffer)
+ (when-let (obj-id (assoc file (vc-got--tree rev file) #'string=))
+ (with-current-buffer buffer
+ (vc-got-with-worktree file
+ (vc-got--cat rev obj-id)))))
+
(provide 'vc-got)
;;; vc-got.el ends here
- [elpa] branch externals/vc-got created (now 8fc127f), ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got af5ef7c 001/145: initial commit, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got f6e414a 003/145: typo, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 5682e01 005/145: add .gitignore, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 23a0b46 002/145: implemented some state-changing functions,
ELPA Syncer <=
- [elpa] externals/vc-got 9e805da 004/145: defalias vc-got-responsible-p to vc-got-root, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 009222a 006/145: add licence, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got f18d3e1 012/145: Summary: add todo to vc-got-diff, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 35b3a91 016/145: correct also the other example, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 4093d2f 008/145: fix vc-got-registered, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 1ca0183 014/145: Summary: fix use-package example, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 08ca3c5 007/145: added readme, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got c0c9a33 009/145: docs improvement, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got 518ede1 010/145: augment vc-got--log, ELPA Syncer, 2021/09/09
- [elpa] externals/vc-got eb85ad2 011/145: implemented remaninig state-changing and some history functions, ELPA Syncer, 2021/09/09