Mercurial for Beginners: The Definitive Practical Guide

Solution 1:

How do you configure it to ignore files?

Ignore is configured in a normal text file called .hgignore in the root of your repository. Add it just like a normal file with:

hg add .hgignore

There are two syntax options available for file matching, glob and regexp. glob is unix-like filename expansion and regexp is regular expressions. You activate each by adding syntax: glob or syntax: regexp on a line by itself. All lines following that will use that syntax, until the next syntax marker. You can have as many syntax markers as you want. The default syntax is regexp, so if you only use regexp you don't need any syntax marker.

You can add comments with #

Example:

# python temporary files
syntax: glob
*.pyc

#editor autosaves
*~

# temporary data
syntax: regexp
temp

Ignore only applies to unmanaged files (i.e. files that are not already checked in). To ignore files that are under version control, you can use the switches -I and -X.

Solution 2:

How do you see what's uncommitted, or the status of your current codebase?

To see a list of files that have been changed:

$ hg status

This will print each file that has been changed along with its status, which can include:

  • M - Modified. The file has been changed and the changes have not been committed.
  • A - Added. The file was not tracked before, but if you commit Mercurial will begin tracking it.
  • R - Removed. The file was tracked before, but if you commit Mercurial will cease tracking it in this and future commits.
  • ? - Unknown. The file is not currently tracked by Mercurial. Committing will have no effect on it unless you use hg add to add it.
  • ! - Missing. The file was tracked but Mercurial cannot find it in the working copy.

To see the changes that have actually been made to the files:

$ hg diff

Solution 3:

How do you create a new project/repository?

$ hg init my-repository