A smart merge utility for todo.txt files.
Updated changelog and added some info about synctodo to the README
synctodo didn't preserve versions of the ultimately merged file; it does now
Add synctodo script to manage sync-conflict files

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~ser/todotxt-merge
read/write
ssh://hg@hg.sr.ht/~ser/todotxt-merge

#todotxt-merge

A smart merge utility for todo.txt files.

File bug reports here.

Build status

Given two files, todotxt-merge produces output with:

  1. All tasks from both lists are in the output
  2. Tasks matched ignoring metadata (priority, projects, lists, dates, completed)
  3. Matched tasks include metadata from both
  4. The second file metadata overrides the first file in the case of metadata conflicts

Rule 2 means that if a task is completed in one list, it's completed in the output.

#Usage

$ 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.

#Building

Install it:

$ go install ser1.net/todotxt-merge

Or build it:

$ hg clone hg.sr.ht/~ser/todotxt-merge
$ cd todotxt-merge
$ go build .

Or download binaries. My PGP ID for verifying the sig is 5E0D7ABD6668FDD1 (on public keyservers).

#Rationale, future, use case

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 fswatch is running. When it detects a new sync conflict file, it runs todotxt-merge and resolves the conflict.

#Credits

todotxt-merge is 129 LOC, thanks to the heavy lifting being done by @JamesClonk's go-todotxt.