5

I'd like to read the source code of one of the popular revision control tools to learn how revision control works. I'd like to read the one that is most readable.

I don't know of an objective, quantitative measure of this, so in the spirit of the WTFs/min comic, I'd like to ask those who have read the source codes of these tools, how many WTFs/min do you estimate each project has?

Muchin
  • 4,887
  • 4
  • 23
  • 25
  • Before starting to dive into the source, I would recommend reading the documentation available. It explains the basics, and is often more helpful for understanding the principles than the code. – Paŭlo Ebermann Mar 17 '11 at 12:19

5 Answers5

5

If you read C well (and some Perl and bash too), adymitruk is right. Git is a good choice.

However, if you're more comfortable with Python, read Mercurial's source. Many of the WTFs/min are going to come from your familiarity with the language and style that the DVCS is written in. Git is written in C, Perl, and Bourne shell, Mercurial is Python (with a bit of C IIRC), and Bzr is written in Python, Pyrex, and C.

You'll also want to take into account what your tool of choice is. If you use Git, you'll understand what each file is implementing. Likewise with Mercurial or Bzr.

Basically, when choosing what tool or language to use (or study), a good axiom is this: go with what you know. You're trying to learn how to implement a DVCS, not how to use a particular system or language :)

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
4

What can be much better than Python in the context of understandable and beautiful code?

Go for Mercurial. I have done it and It's absolutely lovely :)

tamizhgeek
  • 1,371
  • 3
  • 13
  • 25
2

Git is your best option because it is layered. Commands are based on lower level commands. This will allow you to understand what I'd going on conceptually. You can re implement commands yourself from the lower level ones. Finally, implement the low level ones to manipulate the files themselves.

Git was designed with a lot of thought put into it and will give you the best learning avenue.

Also, take a look at Scott Chacon's git internals posts and screen casts.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
1

Before diving into the code it is useful to first get a architectural overview to know where to dive in. For bazaar the following might help: http://doc.bazaar.canonical.com/bzr.2.3/en/user-guide/core_concepts.html http://doc.bazaar.canonical.com/bzr.2.3/developers/overview.html

I found the bazaar code base well organised, clean and readable, probably because it is python and each code change gets reviewed so code documentation is normally amended as per review which in general makes things a lot clearer. If you get stuck you can always ask on IRC or the mailinglist, but I have not needed to do that much at all.

AmanicA
  • 4,659
  • 1
  • 34
  • 49
0

I wonder how much value there is in looking at bad examples, to get an idea of what not to do, rather than just looking at good examples. I've never looked at the source of Subversion or CVS but it might be worth looking through them and understanding why they don't work as well as the DVCSes you mentioned.

Tyler
  • 21,762
  • 11
  • 61
  • 90