A smart merge utility for todo.txt files.
Given two files, todotxt-merge produces output with:
Rule 2 means that if a task is completed in one list, it's completed in the output.
$ todotxt-merge todo.sync-conflict-20210703-174230-73BTXZI.txt todo.txt > new-todo.txt
Also in this repository is a bash script that will watch a directory for Syncthing sync-conflict files and merge them up. It uses fswatch and merges the conflict files in creation timestamp order, rolling every conflict file for the watched file into an ultimate merged file. It then moves all sync-conflict files and the watched file into a backup directory, and replaces the watched file with the merged version. To use this script, make sure fswatch is installed and todotxt- merge is in your path somewhere, and then run:
$ synctodo ~/somedir/todo.txt Watching /home/you/somedir/todo.txt backups will be in /home/you/.cache/synctodo/backup_9uVuGA
If you run it with the
-d option, it'll print everything it does.
$ go install ser1.net/todotxt-merge
Or build it:
$ hg clone hg.sr.ht/~ser/todotxt-merge $ cd todotxt-merge $ go build .
I might add Levestein distance for better task matching; otherwise, it's done.
The tool is in support of resolving sync conflicts when two users are editing
the same todo file. For example, my wife and I share a shopping list, which is
synced across our various devices via Syncthing. Because Syncthing doesn't
do merging, and because Syncthing can often take its time actually syncing
directories, we frequently end up with sync conflict files. My solution is
composed of fswatch and todotxt-
merge: I have the devices set to sync to a home server, on which
running. When it detects a new sync conflict file, it runs todotxt-merge and
resolves the conflict.
todotxt-merge is 129 LOC, thanks to the heavy lifting being done by @JamesClonk's go-todotxt.