This started with a desire to view a timeline on the command-line with
paragraphs separated as they had been created within a checkin. fossil
timeline keeps paragraphs together without a separating newline regardless if
there is one in the comment or not. The Fossil UI separates the paragraphs
using <p>, so it matches the original intent.
While the timeline produced will attempt to be as similar as possible to the original, it will diverge because I believe that the comment should be unadulterated as much as possible when displaying it.
Problem
fossil timeline has logic to condense a commit by removing the newlines.
While it is possible to expand the presentation of the timeline using fossil
settings --global comment-format 16, all newlines between paragraphs are
removed.
Solution
There are a few possible solutions:
- Patch Fossil to stop removing the newlines.
While this would work, it would involve maintaining patches with a changing Fossil source base and installing a patched version of Fossil on different operating systems.
- Write a new client that can query the Fossil database directly without intervention by Fossil.
This requires knowing and interacting heavily with the schema to query the
desired data with various requirements that the command-line tool can do
(i.e., -b <branch>).
- Write a new client that queries a Fossil checkout via the fossil command-line tool as much as possible for better consistency.
This is the best option as fossil timeline --sql can take and incorporate
arguments and display the SQL query it would use. This reduces the amount of
work a client (and its developer!) would need to do to generate a timeline.
Result
Two clients: one written in Zsh and one written in Go.
The Zsh client was first and written with advice from AI bots after many hours
of arguing and teaching them about how to use Fossil. For example, the bots
tried to write an entire SQL query from scratch that left many things out of the
results. When things needed to be fixed, AI bots favored patching the results
instead of fixing the query. Ultimately, discovering --sql saved my sanity.
The Go client came later because the Zsh parsing had hit its limit on speed. I
got the Zsh script down from about 7-8 seconds for listing the entire timeline
for the Fossil repo to about 1.5-2 seconds. Switching to Go lowered that to
about 0.2-0.3 seconds which is almost the same as fossil timeline itself.
I will try to maintain the Zsh script but may just drop it. It is still good for posterity.
Differences
There are a few differences, so far, with the timeline presentation compared to Fossil:
- All meta information about a checkin is on the first line for the checkin just after the timestamp.
- Typically, any links relative to the repo (i.e., forum) show the alternative
text from
[link:alternative text]which hides the link. This is especially troublesome for URLs. The easiest choice is just to display what is in the comment as-is. - Display a newline after every checkin in the timeline.