Creating Mercurial User Repositories

When working with Mercurial, it is often nice to publish your changes on a server as a backup or so others can examine and work with them. If you have Level 1 commit access or higher, then you should have an LDAP account which allows you to push to user repos in the /users directory of

Configuring ssh

So you don't need to type your username every time, add these lines to ~/.ssh/config:

User your-hg@username.domain

where 'your-hg@username.domain' is simply your LDAP username.

Creating a Repository

To do this, run the following command. Use the same command regardless of whether you want to clone an existing repository or create a new, empty one.

ssh clone my-repo1

my-repo1 is the name of the new repository you want to create, not the repository you are trying to clone from.

Running the above ssh command will run an interactive script, prompting you to make some choices (about which repository you want to clone from). It is by and large self-explanatory. When the script is finished, ssh will exit. After 5-10 minutes, your repository should appear on

Editing and deleting your personal repository

Once you have created your mercurial repository, you can edit its description. This description will show up when people visit The process is similar to creating a brand new repository, instead of using the clone action, use the "edit" action. The "edit" action also lets you delete your repository. Please note that the delete action is irreversible.

~ $ssh edit my-repo1

0) Exit.
1) Delete the repository.
2) Edit the description.

What would you like to do? 0

Examining Clones Via the Web

The clone will be visible at  It may take a while for it to show up because of some caching mechanisms that have been put in place. It should show up pretty quickly though, and you'll be able to browse history via a web interface.

Others can also pull changes via http:

hg clone

Pushing Changes

To push changes, use ssh:

hg push ssh://

You may want to add that path to the repository's hgrc, so you don't have to type it every time. Put something like this in .hg/hgrc:

default-push = ssh://

Pulling your changes

You may wish to use this repository to share changes between machines. For this, start by doing the exact same setup on the other machine. In other words, if you have pulled mozilla-central from your first machine, pull it from the second machine. If you have created a queue on the first machine, create a queue on the second machine, etc.

Then, to pull the complete repo:

hg pull ssh://

Mercurial Queue User Repository Workflow

This assumes you have already enabled Mercurial Queues (MQ).

Setup the Repository

  1. Create a new empty repository (say, "my-repo-patches") on, as directed above.
  2. Verify that the repository is visible at
  3. Initialize a patch queue, if you haven't already, with hg init --mq
  4. Create an hgrc file for your patch queue (at .hg/patches/.hg/hgrc) with these contents:
    default =
    default-push = ssh://
  5. You can now manipulate your patch repository using most of the usual Mercurial commands (e.g. status, diff, pull, push, etc.) while specifying the --mq argument.  This avoids the need to cd .hg/patches directory whenever you want to perform actions on it.  For example, both of these commands are run from the same working directory but they work on different repositories.
    hg pull      # Pulls changes in your top-level clone
    hg pull --mq # Pulls changes to the Mercurial Queue user repo.

Commit and push your patches:

hg st --mq                          # Show the changes to your .hg/patches directory to be committed
hg commit --mq -m "Some message"    # Commit the patch changes
hg push --mq                        # Push them to your public repository

Pulling changes

hg qpop -a        # Pop all currently applied patches.  This is required before pulling.
hg pull --mq -u   # Pull and update the patch repository.  
hg merge --mq     # If there are conflicts you may need to merge with your working copy.
hg qpush foo      # Apply patches to continue working.

Document Tags and Contributors

Last updated by: Steffen,