The question isn’t easy to answer. I think it’s because of personal preferences and not because of objective advantages. Anyway I’ll try to explain it in this article. There is also more objective and more extensive comparison of many version control systems available.
Please note, I’m no expert using Subversion, so please mail me if I’ve got something wrong.
Changes instead of versions
Darcs builds on top of patches. A patch is a set of changes to the repository, not only a single file.
Subversion assigns version numbers to files (or better repositories). [Subversion’s version numbering is much more natural than the one from CVS. It assigns the whole repository a version instead of each file a different one (like CVS). That’s a huge step forward, thanks Anders Engström for pointing that out!]
That’s an important difference, if not the most important one. When I work on a project I’m not interested in versions of a file, I’m interested in the changes my colleague made. Most of the time it doesn’t matter to me which files were changed, I just want the feature incorporated to my local copy.
Subversion doesn’t allow the so called cherry-picking, I can’t choose changes selectively. Darcs allows to check out changes selectively, I can check out feature X2 but not X1, even if X1 was made before X2.
Since Darcs doesn’t work on files, I can’t check out files directly. For example if I’d like to have a subdirectory of the repository, using Darcs I’d have to check the whole thing out (all patches).
A little example
Imagine a system administrator using Darcs for his/her configuration files. Think of a central server which holds all users, and some specialized servers holding only a subset of them. Think of a new user for one of the specialized servers (copied from the central server):
- Using Darcs he or she can check out a patch called “new user ‘xyz’” and all files are updated.
- Using Subversion he or she has to look through all changed files and copy the according lines to the according files. Or create the user by hand. Well, to sum it up, I don’t know how to do it in Subversion or CVS.
Of course this is a specialized example, but it illustrates the advantage of patches very well. Darcs is not black magic or something, it works usually, but has it’s limits too.
Subversion and CVS behave like Network File Systems because you either take the latest version or leave it. If you’d like to have a bug-fix, but not the new feature you’ll have to merge the bug-fix into your code. As soon as you’ve changed a prior version of a file you’ll have to merge it with the new version in the repository… .
Subversion is very well suited to keep two copies in sync, but even small differences are hard to get right.
If you’d like to use Subversion to keep track of fine grained changes you’ll have to check in very often1 (for each little change). To do this you’ll need access to the server holding your repository. But what do you do if you’re on the train, in a hotel without internet, or in a small village outside the connected world?
Darcs allows me to work offline but still record my changes very very fine grained (my local repository is a full fledged repository). As soon as I have connectivity I can upload my changes to the server and all my peers can take advantage of the fruits of my work (and start cherry picking).
Interactive nature of Darcs
Most of Darcs’ commands have interactive components. This allows you to select changes for a patch even if you’ve done more. Compare that to Subversion or CVS, using those you can only commit the whole file.
The Darcs Wiki has a nice comparison of interactive Darcs commands to Subversion.
Test before commiting
Subversion and Darcs allow the testing of the code before any change to the repository happens. The difference is that Darcs tests the program on the local machine, and Subversion on the server. Darcs creates a clean copy of the code and runs the defined test suite on that code to make sure that the committed changes are working.
Ad Subversion: What do you do if you develop a program for the Mac on a Mac and your Subversion repository runs on Linux?
In the end it’s about you and your people. If you like Subversion and it’s way of doing things it’s fine. If you prefer CVS because it’s the most mature one, good!
If you need graphical tools to do your work, Darcs my be the worst option for you, it’s still command line oriented. At least I don’t know of a noteworthy GUI.
I like Darcs because it’s simple, and doesn’t clutter my projects with
.CVS directories. Most of the other features aren’t so hot if you’re the only one to use Darcs… . Anyway I’ve got more than a Network File System with version support :-).
Little hint: if you install Ian Macdonald’s bash completion you can expand commands and options with <Tab>. This, of course, isn’t tied to Darcs alone.
1 I wonder why I’d like to check in small grained changes using Subversion because I don’t have the possibility to choose which one I’d like to build upon?
Yes, I’m making fun of subversion here. It’s a great example of a project permanently crippled by dumb architectural decisions.
— Bram Cohen