This page appears to contain material that is no longer relevant. Please help improve this page by updating its content.
How To Handle Multiple Committers
But in Mercurial, in some sense there is no 'main' repository. Users each have their own private repository to commit to and they can pull commits in from other users. This is rather drastically different than the CVS model and it has a number of advantages:
- it's easier to review the work that's being pulled in before merging
- it's easier to time or reorder merges for testing or deployment
- no concept of permissions is needed
- everything is atomic, no need to wait for locks
It is, of course, also possible to push as well as pull, though this is generally used to publish changes in a public place.
However, it is possible (though not recommended) to set up Mercurial to allow multiple users to push to a single repository. This allows Mercurial to be used in a more CVS-like fashion. Below are a couple possible approaches.
The shared SSH method
The typical way to create an SSH-reachable repository is to create a special account for that project, create the project under that account, then provide each user with an SSH key that's authorized to use that account. See the guide to shared SSH for general setup details.
Another way to use SSH is just to provide regular SSH access and set up the depot with the "filesystem method", below. The only role of SSH in this case is that of a mechanism for reaching the remote repository.
The HTTPS method
The repository will be shared via a web server, which can also allow pushing. The security is handled by the web server. See the guide to publishing repositories for some guidance.
The filesystem method
The idea here is to create a repository that is accessible by members of a certain user group. Multiple users will be able to access it if they belong to this group.
The following steps apply to Unix-like operating systems:
Add a new group to /etc/group. The recommended method for accomplishing this varies from system to system, but the end result is a new line in /etc/group like the following:
Here, project is the name of the group.
- Create a repository that's writable by that group:
mkdir /home/mercurial/project cd /home/mercurial/project hg init chgrp project .hg .hg/* .hg/store/* chmod g+w .hg .hg/* .hg/store/* chmod g+s .hg .hg/store .hg/store/data
The chgrp command marks the project as belonging to the project group.
The first chmod command marks the repository data writable by that group.
Finally, the second chmod command sets the 'setgid' bit on the project directories, which causes new files created in those directories to be marked as belonging to that group (rather than the user's default group).
If you are using a version of Mercurial older than 1.0, it's important that each user's umask be set to 002 or something similar. If it's set to 022, group write privileges will be masked off for files that users create, causing other users to be unable to modify them.
You can change the default umask for a user by editing their ~/.profile and adding the line...
Alternatively, you can edit /etc/profile to change the system-wide settings. Changing the /etc/profile will not work if people check in stuff with the hg command, as that file isn't read by non-interactive shells, /etc/bash.bashrc is a better place to put the system-wide settings.
Otherwise since Mercurial 1.0, the default permission is inherited from .hg/store.
Now you're ready to go:
hg clone /home/mercurial/project cd project [make changes] hg commit hg push /home/mercurial/project
Keeping in sync
You may sometimes get a warning like this when you push:
abort: unsynced remote changes!
This means you should pull the latest changes from project before pushing.
You may also get a warning like this:
abort: push creates new remote branches!
This means you've probably forgotten to merge changes you've pulled with the changes you're trying to push.
As always, sync early, sync often!