• SOURCE DISTRIBUTION VERSION CONTROL



We all know that the shower is the place where every great software engineering
idea is born. This is one of those.

As many others, I've kept my dotfiles in a git repository for a long time. When
getting a new computer, I clone the repository and start symlinking like crazy.

Sure, there might be several better ways of doing it, but that how I've done it.

I started thinking, "what if I could keep track of changes in my dotfiles, while
they live in different locations in my filesystem?". People started mentioning
things like git-annex and other tools, but I want to write the tool myself.

So, as I usually do before writing code, I started writing a bunch of notes in
a TODO-file. Down below is the content of that file.

But first a few bullet points on the desired outcome:
    - A tool that monitors specified files for changes.
    - If changes are found, store it in a sqlite3 database.
    - Store filename, file path, previous version database id, change date,
      diff, old file checksum (sha512?), new file checksum.
    - The file can live anywhere in the filesystem, or remote if that remote
      path is mountable in the local filesystem (ssh, nfs, etc).
    - You should be able to push the repository to a remote location, and pull
      it back to another computer. (much like git, mercurial, etc).
    - One should be able to run the tool manually.
    - The tool should be runable via croontab (flags for automation of commits,
      etc).



Here's my TODO file so far:
--------------------------------


Small tool, to be run with crontab, which monitors specified files for changes.

Use v.util.diff to check differences. If changes are found, store it in a sqlite3
database.

To be stored:

filename, file path, previous version database id, change date,
diff, old file checksum (sha512?), new file checksum. Maybe generate patch and
store path in db to patch file?

--
flow
--

keep a local folder for storage. initially ~/.vdiff_store
do a copy of files at first run. store in db with checksums, dates, etc, except
diff.

when change is found, compare new version with stored version, store changes
to databse, then copy new version to ~/.vdiff_store and overwrite old file.

maybe folders in ~/.vdiff_store should be versioned and stored in db to easily
read back a few versions without applying (or redacting) diff from db.

AMMEND:
This should be a decentralized version control, in the sense that you keep one
store (and db) and files can be located anywhere in disk, nfs storage or ssh
path. It should not be mandatory to keep the version controlled files in a
single folder. Git, for example, tracks from one folder and down. You cannot
track multiple folders, in one git repository, unless those folders are both
under another single folder which is the folder being tracked.

--
db schema
--

id integer primary key auto increment
ident text default '' // this should probably be a uuid
file_name text default ''
previous_id integer default 0
change timestamp default current_timestamp()
old_checksum text default ''
checksum text default ''
file_path text default ''
store_path text default ''
diff text default ''