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.
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
SourceForge.net provides the following features in its Mercurial offering:
Several Mercurial clients are supported, including:
Existing repositories may be imported via a normal Mercurial push (since Mercurial is a distributed SCM).
To create a new repository:
The above instructions may be repeated using a different label and path to create multiple repositories.
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.
The following options are available, under the "Admin" section in the left sidebar of your repository:
Specify here a space delimited list of filename extensions that should be viewable in the browser (ie., plain-text files)
The code browser typically will be refreshed automatically when there's a new change, but it can also be manually refreshed if necessary
Specific permissions for the repository can be configured here. Fine-grained permissions controls are not supported (e.g. restrict access by specific paths within a repository), if that sort of access control is required, consider creating multiple repositories with different permissions.
This will delete the repository on our servers, note that while this is normally very quick, there is occasionally a delay in removal.
We provide read/write access to Mercurial via ssh or https. ssh will provide better performance than https, and should be used whenever possible.
To access a Mercurial repository, configure your Mercurial client as follows (replace PROJECTNAME with the UNIX group name of the project, and the default REPOSITORY is 'code'):
If ssh does not work for you, you may use https instead, however, access will be slower:
The read/write protocols detailed above can also be used for read-only access (just remove the "USERNAME@" portion). In addition, you may also use the http protocols with the same URLs.
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.
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@hg.code.net/p/PROJECTNAME/REPOSITORY PROJECTNAME-REPOSITORY
The first time you try connecting to the hg.code.sf.net host, you should see a message similar to the following:
The authenticity of host 'hg.code.sf.net (184.108.40.206)' can't be established. RSA key fingerprint is 86:7b:1b:12:85:35:8a:b7:98:b6:d2:97:5e:96:58:1d. Are you sure you want to continue connecting (yes/no)?
Before typing 'yes' to accept the host fingerprint, ensure the fingerprint is correct for the host. You can find a listing of SSH host keys in the SSH Host Key Fingerprints list. If you receive a host key warning, please contact the SourceForge.net team.
The clone command will create a PROJECTNAME-REPOSITORY 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.
If you already have a repository that you want to publish on SourceForge.net, you can publish it by first creating a new repository on SourceForge.net as described above (using the Mercurial tool in the administrative interface). This new repository will be completely empty and just be used as a container for your existing repository.
To replicate your existing repository, first clone the new repository as described above. This will create a local clone of the new repository in your own filesystem. Then, enter this clone and pull changes from your existing repository:
$ cd PROJECTNAME-REPOSITORY # the new, empty repository $ hg pull path-to-existing-repository
Since the new repository is empty, Mercurial will happily perform the operation. (Had the new repository not been empty, Mercurial will have complained about you pulling changes into an unrelated repository.)
You may now push the contents of the new repository back to SourceForge.net:
$ hg push
What you have effectively done at this point is to clone your existing repository to the SourceForge.net server. In other environments, this would have been done using the following command:
$ hg clone path-to-existing-repository ssh://USERNAME@hg.code.net/p/PROJECTNAME/REPOSITORY
However, due to various restrictions on the ssh login specific to SourceForge.net, the above command will not work. Thus, the create, clone, pull, push workflow is required to achieve the same thing.
Direct access to the bare repository is also available via [SSH], when logged into the shell, it will be available at:
Note that the directory is mounted during the shell creation, if you create a new repository while an existing shell session is still active, use the
shutdown command on the shell and start a new session.
Direct access to the repository can be used to install custom hg hooks server-side.
Note however, that a
changegroup hook is used for site-integration, if this hook is changed, the code browser view may not longer automatically update.
If you need to re-create the default
changegroup hook, the entry in the server-side .hg/hgrc file is as follows:
[hooks] ; = [the next line is required for site integration, do not remove/modify] = changegroup.sourceforge = curl -s http://sourceforge.net/auth/refresh_repo/p/PROJECTNAME/REPOSITORY/
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 hg.code.sf.net::p/PROJECTNAME/REPOSITORY .