Recording Changes in a New Changeset

We can modify files, build and test our changes and use hg status and hg diff to review our changes, until we’re satisfied with what we’ve done and arrive at a natural stopping point where we want to record our work in a new changeset.

The hg commit command lets us create a new changeset; we’ll usually refer to this as making a commit or committing.

Setting Up a Username

When you try to run hg commit for the first time, it is not guaranteed to succeed. Mercurial records your name and address with each change that you commit, so that you and others will later be able to tell who made each change. Mercurial tries to automatically figure out a sensible username to commit the change with. It will attempt each of the following methods, in order:

  1. If you specify a -u option to the hg commit command on the command line, followed by a username, this is always given the highest precedence.

  2. If you have set the HGUSER environment variable, this is checked next.

  3. If you create a file in your home directory called .hgrc with a username entry, that will be used next. To see what the contents of this file should look like, refer to Creating a Mercurial configuration file.

  4. If you have set the EMAIL environment variable, this will be used next.

  5. Mercurial will query your system to find out your local user-name and host-name, and construct a username from these components. Since this often results in a username that is not very useful, it will print a warning if it has ...

Get Mercurial: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.