views:

101

answers:

4

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)

+1  A: 

Darcs is written in Haskell, but it is quite large: 40 KLOC. Mercurial is about 40 KLOC too, but its core is about 20 KLOC.

Andrey Vlasovskikh
+2  A: 

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 MYYN
Yes, but its early design and interface were so divergent from most VCSes or DVCS ideas that I don't know that it would be overly helpful for DVCS educational purposes.
Michael E
+2  A: 

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.

Jörg W Mittag
Now *that* (i.e. Amp), I would consider it as the right answer for this question. +1
VonC
I think dulwich is what I was looking for. Thanks.
Naveen
unfortunately dulwich isn't complete... git-merge is not implemented, which is the part of git i am most awed by. Out of the remaining implementations: https://git.wiki.kernel.org/index.php/Interfaces,_frontends,_and_tools#Interfaces_to_other_programming_languages It looks like msysgit and jgit are the most mature. msysgit is nicely browsable with an msvc .sln file.
Naveen
+1  A: 

Have a look at fossil distributed versioning it's only 350kb.

http://www.fossil-scm.org

dalton