I am interested in writing a toy DVCS.
What is the smallest DVCS around to study ?
(I don't need ssl, ssh, svn compatibility etc... it should just be able to do local repositories)
views:
101answers:
4Darcs is written in Haskell, but it is quite large: 40 KLOC. Mercurial is about 40 KLOC too, but its core is about 20 KLOC.
The initial version of git
commit e83c5163316f89bfbde7d9ab23ca2e25604af290
Author: Linus Torvalds <[email protected]>
Date: Thu Apr 7 15:13:13 2005 -0700
had 1,064 lines of code (ansic=822,sh=242).
For a chronicle, see:
Initially making a commit looked like this:
$ init-db
$ edit file
$ update-cache –-add file
$ edit file
$ show-diff
$ update-cache file
$ T=$(write-tree)
$ P=$(cat .dircache/HEAD)
$ C=$(echo "My commit" | commit-tree $T -p $P)
$ echo $C >.dircache/HEAD
The actual core of Git is rather small. Unfortunately, it's not written in a programming language that is amenable to easy understanding, and it is riddled with performance optimizations that are not relevant to the actual operation.
However, there are several alternative implementations of Git, in particular the Dulwich library, which is written in Python.
There's also Amp, whose goal is to provide unified interfaces to all major distributed version control systems. At the moment, they only implement Mercurial, but Git, Bazaar and Darcs are planned as well. Now, Mercurial is written in Python and Amp in Ruby which are both similarly expressive, so you might think that the difference isn't that big. However, Amp is designed so that you e.g. use the Mercurial commands on a Git repository or Darcs commands with Bazaar semantics on a Mercurial repository, so there is a very clear separation between those layers. And Amp is designed so that even non-programmers can write their own personalized version control system using Amp's building blocks, so the code is extremely simple and straightforward.