Monday, August 22, 2011

Home Mercurial Server

I hope I'm not the only one who had this problem:
I've been working on some code demos and web designs and wanted to having it under source control, so I could keep track on changes, work from multiple computers and generally have a backup for everything.
For normal projects, I guess this should be done as an open-source project on bitbucket or github, but in some cases it's simply more convenient to have the repository at home.

So, I installed a Mercurial server. Want to know how?

The only thing you'll need is the Mercurial installation for your favorite OS (yes, Windows included). After installing it, run
hg init RepoName
this will create a repository called RepoName under the current directory.
For the next part, I'll assume the server is accessible only inside the home network, and there's no need to configure extra security measures. So, create a script that servers this repository inside the the repository directory:
hg serve --config web.push_ssl=No --config "web.allow_push=*"
All you have to do now is to schedule this script to run on boot time.
Now, from any machine on the network you can use commands such as:
hg clone http://ServerName:[probably_8000]
to work with your new Mercurial repository.
That's it.

Having a "development server" can be very handy, as it could also hold other documents (NAS functionality), personal wiki, local deployment server, etc.

2 comments:

  1. Moshe, why not use git, it's distributed by nature, always holding a local repository, that can be pushed to an outside repository if you finally wish to take it out of your home.
    No server needed, and it's quite fast (of course it very-very fast on Linux, but it's OK on Windows).

    I've been using it for a while with TortoiseGit, and it's a blessing compared to more primitive source-control schemes, like SVN.

    Check out this excellent video from Google, where Linus Torvalds himself explains how he came up with making git, and how it's used.
    http://lksz.me/oVkIlw

    ReplyDelete
  2. Gal, my reply deserves a full post, but I don't want to start a flame war, so I'll keep it short and in order with your statements:
    1. hg is distributed by nature as well. just like git, it holds a local repository that can be pushed anywhere.
    2. hg is fast. the server isn't needed for plain "hg init" cases. it is needed in my special case when I develop something on my laptop, and another thing on my desktop, and want to have them easily merged and managed.
    3. svn is primitive. TortoiseHg is a blessing as well :) also, visual studio integration is nothing but perfect.
    4. I know this video by Linus. Keep in mind Mr. Torvalds is a total jerk (Linus, please don't be mad at me), and that he was seriously hurt by the previous source control used by the Linux kernel.

    tl;dr
    ======
    Gal, why not use Mercurial?

    ReplyDelete