الأربعاء، 10 ديسمبر 2008

Switching to Mercurial

So far, I've stuck with CVS, with occasional excursions to SVN. Both CVS and SVN are centralized version control systems. But I like the idea of distributed version control systems (DVCS) and it seems that the SVN developers agree. With a DVCS, everything is a repository. You don't have a working copy that you check out, you have a local repository that is cloned from another one. Changes are always pushed from one repository to another one. This means that you can use any number of intermediate repositories with the following advantages:
  • Offline use: You can check in and have the complete history even when you are not connected.
  • Branches: If you have something that is not yet finished (say, when moving from your work computer to your home computer) or want to try out things, you can always introduce an intermediate repository. If you are not happy with where you ended up, you can discard this repository, otherwise you push its changes.
There are quite a few DVCS around; you might have heard of Mercurial (used by Sun's OpenJDK), Git (used by the Linux kernel), or Bazaar. I've decided to use Mercurial, because it is more popular than Bazaar and less complicated than Git.
Quickstart:
  • Install: a binary (easy_install works really well)
  • Test on command line: hg debuginstall
  • If the test fails on Mac OS X: In Terminal, uncheck the option “Preferences -> Settings -> Advanced -> Set LANG environment variable on startup”.
  • Eclipse: Merclipse plugin (simpler than Mercurial Eclipse).
  • After installing it, check its section among the Eclipse preferences and make sure that it finds the “hg” command.
  • If not, there are two ways to fix things under Mac OS X: Start Eclipse from the command line (where it uses the same environment variables as during the debuginstall test). Or set the GUI environment variables in ~/.MacOSX/environment.plist
  • Netbeans: support is built in
Things to know:
  • Authentication under Merclipse: work-around via user:password@http://hosting.org/repo/
  • Cannot group several projects in one “module”, need a repository for each.
  • Mercurial files are only in the top-level directory: .hg/ and .hgignore
  • More information: at the Mercurial web site.
First steps (uploading)
    cd mydir
hg init # turns the directory into a repository
hg stat # check what files are visible to Mercurial, edit .hgignore accordingly
hg add # add all files that are visible to Mercurial
hg commit # commit the changes to the local repository
hg push http://hosting.org/repo/ # push change (URL only needed for the 1st time)
First steps (downloading)
    hg clone http://hosting.org/repo/
# perform changes
hg commit
hg push
Mercurial hosting: There are many great options if you want to host your Mercurial repository on a public server. Free examples:
  • freeHg.org: Only hosting, nothing else (issue tracker, wiki, ...)
  • Bitbucket: Nice clean interface, adequate free plan.
  • ShareSource: For open source projects, a bit more complicated than Bitbucket.

ليست هناك تعليقات:

إرسال تعليق