CVS vs Mercurial

Açık Kaynak, ytulinux

Hi, i decided to write my technical articles in English to share them with more people.

I wanted to compare CVS with Mercurial seeing lots of companies that has a history with CVS just cant decide to change their VCS seeing the difficulties. But lots of big projects like PostgreSQL(to git Article) , mozilla (to mercurial Article), OpenJDK (to mercurial Post) made this decision and we can understand from blog posts of the developers that theyre quiet happy about the change. I couldnt find a good article that clearly explains the difference between CVS and Mercurial despite there are bunchs of SVN vs Mercurial or Mercurial vs Bazaar bla bla articles on the internet.

If i had mistakes please tell me about it. Here we go…

Architecture

First of all, CVS has a server-client architecture like SVN, so if you have some connection problems this means you cant make commits. People who didnt use a distributed VCS (Version Control System) wont understand this, but lets explain.

Distributed VCS means that you dont check out a revision/changeset (Think that revision=changeset for now, you can understand the small difference later reading about them http://hginit.com/ it is the best source to learn mercurial) from the server. You clone it. Cloning means you get a fully functional repository from the server. You can serve it from your machine telling people your IP.

Use Cases

Lets talk about the use cases of CVS and Mercurial.

To begin making changes on the code, you check out the codes from CVS repo. You make changes, after that you commit the changes to the server side. This is the CVS style.

Mercurial style differs a lot. You clone the repo, you make changes, you commit, and push the commits (this means you can have multiple commits on your local machine that the server doesnt know till you push them) to the server. So you can clone the repo, open your laptop at your voyage to another city on the bus, make lots of commits, and push the changes when you have the connection.

In Mercurial, scope of change is the repository, this is another strong difference from CVS because CVS’s scope of change is file. You can get a snapshot of the whole repository of a certain changeset number with mercurial, you can get the history for a directory or the whole repository and see the last committers (or the name of it: “Blamelist” haha)

Features

Variations of network protocols are supported in mercurial. I wont talk so much about this issue because you can understand clearly from the table below.

File renames-copies-moves are not supported in CVS, so this is very problematic to me. If you change name of a file or move it, CVS gives up tracking it. I refactor so much so i change names and directory hierarchies, and i dont like seeing a blank history behind a file.

UNIX programs widely use symbolic links, so mercurial is one step forword once again. But people use installation scripts for that purpose and i dont think its a big point like the previous ones. (If you like pain :P)

Clean Commits?

Hmm i want to talk about another issue that is related with scope of the change. When i said “oh no i made a broken commit to the code base” to guys who are used to CVS turned me and said “What is a broken commit?”. I didnt know the scope of CVS is file -I was using Eclipse plugin for commits-, and i didnt understand why they were astonished at my comment. If your VCS’s change scope is the repo, you can have the purpose of having clean revisions, this means each revision you get from the repo works when you build it.

So i will continue talking about this issue from SVN-Mercurial side (because CVS simply cant have the purpose to have clean commits), comparing server-client and distributed architecture. In Mercurial we can make a commit, say “Oh wait i forgot to change x too”, rollback it, making the commit again and then push the commits to the server. It is totally safe, no one will take that commit that we are reverting while we are arranging the new commit, because it is on our local repo, not on the server yet. Also you can use rebase (no you wont (: ).

A very important thing indeed; you should move-rename-copy files from command line if you use eclipse plugin of mercurial because it doesnt support them. Keep this in mind.
If you want to play with Mercurial, you can just clone a random repository from http://www.bitbucket.org and  and try Mercurial features on your local machine. If you use Eclipse, download MercurialEclipse. If you want to install Mercurial on your server you can read http://mercurial.selenic.com/wiki/PublishingRepositories.

Who uses Mercurial?

OpenJDK, NetBeans, Mozilla, OpenOffice, Symbian OS, Go Programming Language, Illumos et cetera

A table that contains the differences between CVS and Mercurial:

CVS Mercurial
Architecture Server-client Distributed
Changes Named Revisions Changesets
Revision Numbers are numbers are numbers or SHA-1 hash
Network Protocols pserver or ssh http, https, ssh, email bundles
Written in C Python, C
License GPL GPL
Scope of change Revisions are created per commit to a file Commits to multiple files can be made, this relates the changesets with the whole repository.
File renames-moves-copies not supported supported
Symbolic links not supported supported
Merge tracking not supported supported
Rebase not supported supported
Revert Remove-then update supported
Rollback Nope Hell yeah
IDE plugins Eclipse, Kdevelop, Intellij Idea,Emacs, Komodo IDE, BBEdit, Visual Studio 2008 Intellij Idea, Eclipse, NetBeans, Visual Studio 2008, Emacs, Vim, Komodo

Bu yazı toplamda 5691, bugün ise 0 kez görüntülenmiş

No Comments