Menu

Mercurial

There is a newer version of this page. You can find it here.

What is Mercurial?

Mercurial (hg) is a Source Code Management (SCM), a tool for software developers which supports collaborative development of software within a team, and the tracking of changes to software source code over time.

Mercurial is used by developers, and advanced users who need the very latest changes to the software (before releases occur). Software users generally do not need Mercurial; typically they will download official file releases made available by the project instead.

Developers should familiarize themselves with Mercurial by reading the Mercurial Documentation.

Modern SCM facilities

Here's a nice writeup of why you should consider using a Distributed Version Control System (DVCS), and a comparison of the major DVCSs: http://www.infoq.com/articles/dvcs-guide

Features

SourceForge.net provides the following features in its Mercurial offering:

  • All 1.4.1 features of Mercurial are supported.
  • Developer (read/write) access is provided via ssh.
  • anonymous (read-only) access are provided via hgweb over HTTP ("http://").
  • Several Mercurial clients are supported, including:
    • The official Mercurial client (MS Windows, Mac OS X, Linux, BSD).
    • The Windows shell extention client, TortoiseHG (MS Windows).
  • Repositories may be viewed via web browser using the hgweb.
  • Existing repositories may be imported via a normal Mercurial push (since Mercurial is a distributed SCM).
  • Repository access may be granted or revoked from a developer using the Project Admin interface.
  • Repository backups and mirroring may be performed using rsync or Mercurial clone.
  • Service usage is not restricted by quotas.
  • Multiple repositories are supported.

Management

Mercurial service may be enabled for your project as follows:

Login as a project administrator and click on the Admin icon in the navigation bar.
Click on "Tools."
Click on "Mercurial."

Your repository will be instantly enabled.

Once Mercurial has been enabled, you may wish to adjust permission grants for your users, if you need to disable one or more user's ability to make changes in the Mercurial repository.

The standard way to modify the contents of your repository is using a Mercurial client as detailed in Distributed revision control with Mercurial. Refer to the Getting Started section for how to make your first commit to your new repository.

Administrators may also manually manipulate their repository via the site interactive shell service.

We strongly recommend that when modifying a repository, other committers be notified of the direct edit window and that you make your own backups prior to editing the content so you can restore it readily yourself in the case of an accident.

Access

To access a Mercurial repository, configure your Mercurial client as follows (replace PROJECTNAME with the UNIX group name of the project, and REPONAME as the name of the Mercurial repository):

http://PROJECTNAME.hg.sourceforge.net:8000/hgroot/PROJECTNAME/REPONAME (read-only)
ssh://USERNAME@PROJECTNAME.hg.sourceforge.net/hgroot/PROJECTNAME/REPONAME (read/write)

The default repository name is the same as the project's UNIX group name, e.g

ssh://USERNAME@PROJECTNAME.hg.sourceforge.net/hgroot/PROJECTNAME/PROJECTNAME

For those developers who have Mercurial access enabled to more than 16 projects, you may need to include your PROJECTNAME as a part of the USERNAME (appended after a comma) in order to work around a Linux permission limitation:

ssh://USERNAME,PROJECTNAME@PROJECTNAME.hg.sourceforge.net/hgroot/PROJECTNAME/REPONAME (read/write)

Authentication

The read-only access does not prompt for a password.

The read/write access uses your ssh password or ssh key to authorize your access. To perform write operations, your project administrator must have granted you write access to the repository.

Getting Started

Note: - For all examples below, "PROJECTNAME" represents a SourceForge.net project UNIX name and "USERNAME" represents your SourceForge.net user account.

Your project's Mercurial repository will be completely empty at the start, but since Mercurial allows you to clone a repository with no content, you can do a clone to get started:

hg clone ssh://USERNAME@PROJECTNAME.hg.sourceforge.net/hgroot/PROJECTNAME/PROJECTNAME

That will create a PROJECTNAME directory with the hgrepository inside the .hg subdirectory. If you're starting fresh, use whatever combination of "hg add" and "hg commit" commands you want to create one or more commits in your local repository. When you are ready, run "hg push" to push your commits to our server.

Users should commit to their project repository using their SourceForge.net username or email address (USERNAME@users.sourceforge.net). Several methods are supported for configuring this, please refer to the Mercurial Documentation for the supported methods.

Creating Multiple Repositories

To create a new repository, you need to access the Shell service, then follow these steps:

Navigate to your repository
cd /home/scm_hg/P/PR/PROJECTUNIXNAME

PROJECTUNIXNAME is the UNIX name of your project
P represents the first letter of that name, and PR the first two letters of the name.
Run mkdir DIRNAME (where DIRNAME represents the name of the repository to be created)
This creates a new directory with the name you want for the repository.
Run hg init DIRNAME
This will initialize a new repository at that directory
Run chmod -R g+w DIRNAME

This will set the permissions on the repository so that all project members with Mercurial Access can write to it.
Notes: Developers should not nest directories / repositories. Directories should only be created the top level directory of repository. Be sure to make backups prior to editing your repository contents.

Backups

SourceForge.net performs routine backups for all of our servers and will restore from these backups in the event of catastrophic server failure. We encourage projects to make their own backups of Mercurial data as that data restore can be performed by the project in the event of accidental data destruction by a member of the project team.

Backups of a Mercurial repository may be made using rsync.

Example (replace PROJECTNAME with the UNIX group name of your project):

rsync -av PROJECTNAME.hg.sourceforge.net::hgroot/PROJECTNAME/* .