-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjujutsu-log.el
105 lines (97 loc) · 4.34 KB
/
jujutsu-log.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
;;; jujutsu-log.el --- Description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2024 Benjamin Andresen
;;
;; Author: Benjamin Andresen <b@lambda.icu>
;; Maintainer: Benjamin Andresen <b@lambda.icu>
;; Created: August 19, 2024
;; Modified: August 19, 2024
;; Version: 0.0.1
;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp
;; Homepage: https://github.com/bennyandresen/jujutsu-log
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;; Description
;;
;;; Code:
(require 'ht)
(require 'dash)
(require 's)
(require 'jujutsu-core)
(require 'jujutsu-vars)
(require 'jujutsu-formatting)
(defun jujutsu-log--get-log-entries (&optional revset)
"Get status data for the given REVSET."
(let ((revset (or revset jujutsu-log-revset-fallback))
(template (ht (:change-id "change_id")
(:change-id-short "change_id.short(8)")
(:change-id-shortest "change_id.shortest()")
(:commit-id-short "commit_id.short(8)")
(:commit-id-shortest "commit_id.shortest()")
(:empty$bool "empty")
(:bookmarks$list (jujutsu-core--template-list "bookmarks"))
(:hidden$bool "hidden")
(:author-email "author.email()")
(:timestamp "author.timestamp().format(\\\"%Y-%m-%d %H:%M:%S\\\")")
(:current-working-copy$bool "current_working_copy")
(:remote-bookmarks$list (jujutsu-core--template-list "remote_bookmarks"))
(:git-head$bool "git_head")
(:root$bool "root")
(:immutable$bool "immutable")
(:parents$list (jujutsu-core--template-list "parents.map(|c| c.change_id())"))
(:description "description.first_line()"))))
(--> (jujutsu-core--map-to-escaped-string template)
(jujutsu-core--log-w/template it revset)
(jujutsu-core--split-string-on-empty-lines it)
(-map #'jujutsu-core--parse-string-to-map it))))
(-comment
(-> "@ | ancestors(immutable_heads().., 18) | trunk()"
jujutsu-log--get-log-entries
jujutsu-dev-dump)
)
(defun jujutsu-log--format-log-entry (data)
"Format a status entry using DATA with fontification."
(-let* [((&hash :change-id-short chids :change-id-shortest chidss
:commit-id-short coids :commit-id-shortest coidss
:bookmarks$list bookmarks :empty$bool empty :description desc
:root$bool root :author-email author-email
:timestamp timestamp :immutable$bool immutable
:current-working-copy$bool cwc)
data)
(node (cond (cwc (propertize "@" 'face 'magit-keyword))
(immutable (propertize "◆" 'face 'magit-log-date))
(t "○")))
(author-email (if author-email
(propertize author-email 'face 'warning)
""))
(empty (if empty
(propertize "(empty) " 'face 'warning)
""))
(timestamp (if timestamp (propertize timestamp 'face 'magit-log-date)
""))
(bookmarks (s-join " " bookmarks))
(bookmarks (if bookmarks
(s-concat (propertize bookmarks 'face 'magit-branch-local) " ")
""))
(change-id (jujutsu-formatting--format-id chids chidss))
(commit-id (jujutsu-formatting--format-id coids coidss))
(desc (if desc
(propertize desc 'face 'jujutsu-description-face)
(propertize "(no description set)" 'face 'warning)))]
(if root
(format "%s %s %s %s\n"
node
change-id
(propertize "root()" 'face 'magit-keyword)
commit-id)
(s-join ""
(list
(format "%s %s %s %s %s%s" node change-id author-email timestamp bookmarks commit-id)
"\n"
(format "│ %s%s\n" empty desc))))))
(provide 'jujutsu-log)
;;; jujutsu-log.el ends here