What if we would implement a "3-way-merge" system into TW?

I’ve long been interested in re-implementing the tiddler store as an append-only log, implemented using the DiffMatchPatch primitives. I had always imagined it being done at the JS layer, though, so that it could handle all tiddler writes, not just those resulting from tm-save-tiddler.

I’m currently exploring the other way around. Instead of appending a series of patches to get the from the original tiddler to its current version, I’m tracking the changes backwards. The current tiddler always has the complete text. To see earlier versions of it, I apply the corresponding “inverse” patches to go back in time.

The upside of this approach is that for pruning, one can just delete all “history” data before day X and be done with it (unless one wants to keep the initial version). We do not need to compute the state on day X from all earlier changes and then throw away the old stuff.
Also, showing the current version is much faster without needing additional memory or initialization time during boot (to calculate the current versions)…

Trapping the tm-save-tiddler only indeed prevents me from tracking changes made via the ActionWidgets, so it won’t make sense to track state and temp tiddlers – which shouldn’t be versioned anyway – and maybe config tiddlers.

Have a nice day
Yaisog

2 Likes

That’s actually not true. Upon further reflection I came to realize that any field of any tiddler can directly be edited by binding it to an $edit-text widget. There would be no way of creating backups automatically for that, unless one does so after each $:/config/Drafts/TypingTimeout. Diffs could only be initiated manually. Since at that point one does not have a previous version to compare to with “inverse” patches (the last patch is based on the current version which has changed in the meantime). So, maybe the past-to-now forward approach is more sensible after all. With on-demand (or automatically triggered, e.g. upon tm-wiki-save) diff snapshots, one could generate a diff of all changed tiddlers in the wiki by comparing their modified date (is this always set?) and making a new diff if necessary…

@jeremyruston: When did you say that append-only tiddler store will go live? :wink:

I made a rough draft of a PR with the changes needed to install alternate wiki stores from plugins:

It is not functional at this point, but indicates a viable approach and clarifies the work needed to get it up and running.

1 Like