This is an implementation of a git-like version control system.
Only the core functionality is (will be) implemented. Full compatibility, both on the internal structures (specially the index) and the objects in the repo is out of scope. Having said that, the internal design of git is used as inspiration or used directly when possible. For example, the repo structure is the same as in git.
Building something is the best way of understanding it. My understanding of Git is limited, so…
This is also an opportunity for me to implement a non totally trivial project in modern Python, so it’s a nice way of killing two birds with one snake.
The implementation is quite straigtforward, if not very refined. The main structure can be understood by having a look at the Protocols of the building blocks of the system, defined in cv/api.py.
Just download the repo, put it in some directory in your PYTHONPATH, which makes it possible to invoke it with ‘python -m vc’. In order to make it more ergonomic, you can alias it:
$ alias vc='python -m vc'
For the time being, there are only a handful of commands implemented, with very few options. The following already (partially) work:
$ vc init
$ vc add <files>
$ vc commit -m <msg>
$ vc hash-object [--stdin] [-w] <file>
$ vc cat-file [-e] [-p] [-t] <hash>
$ vc status
$ vc log [--oneline]
$ vc checkout [-b] <commit-or-branch>
$ vc branch <branch>
$ vc diff <files>
For the complete list you can just type vc, for the complete list of available commands or vc <command> -h, for information of the options supported by a given command.
At the time of writing this README, this is the output for two cases.
$ vc
Command required. Available commands: init, hash-object, cat-file, add, commit, status, log, checkout, branch, diff
$ vc hash-object -h
usage: __main__.py [-h] [-w] [--stdin] [file]
Calculate hash and, optionally, write objects to DB
positional arguments:
file name of the file to read from
options:
-h, --help show this help message and exit
-w Write object to DB
--stdin Read objecdt contents from stdin
Otherwise, just use the source, Luke! Command <x> is implemented in vc/command_<x>.py.