Mercurial: Collaborating on a Windows Network Using Shares

You might feel the need to publish Mercurial repositories in a central location and collaborate using that. This is really useful when:

  • You are working from 2 or more workstations or laptops.
  • You are in a small team and there are 2 or more people working on the project.

Publishing a Mercurial repository in a central location enables different people or computers to push and pull from it. There are a few common ways to do this:

  • hg serve: Real easy and quick to setup with simple features.
  • SSH: Not as easy on Windows as on Linux. OpenSSH server is the most common option, but it comes with Cygwin and all its problems.
  • HTTP: Requires quite a lot of configuration on Windows.
  • SMB: If you are on a Windows network, your computers or team is small in number and your needs are simple, then using a Windows share is very compelling!

You can start publishing Mercurial repositories using Windows shares in just a few minutes:

  1. Designate one computer as the central repository server. Let us call it A. It can be the workstation of the one of the team members, it does not really matter. Other computers, B and C, should be in the same Windows network as A.
  2. Create a directory on A, say D:\HgReps and move all your current repositories to it. New repositories in the future should also be created here.
  3. Share the directory on A, so it becomes \\A\HgReps. Give only the team members who use A, B and C access to read and write to this share. You could also give read access to other users who you wish only pull from A. These access permissions should be very easy to configure if you are in a well set up Windows domain.
  4. Point all the current working directories on A, B and C to push and pull from \\A\HgReps. To do this, open the .hg/hgrc file in each working directory and edit it so it points to A. For a project named Foobar, the .hg/hgrc file looks like:
    [paths]
    default = \\A\HgReps\Foobar
    

All this setup is ridiculously easy to do for a small team and everything just works without much configuration. Another nice side-effect is that you can backup the D:\HgReps on computer A easily and grab all the team’s commits.

About these ads