Chapter 7. Filenames and Pattern Matching

Mercurial provides mechanisms that let you work with file names in a consistent and expressive way.

Simple File Naming

Mercurial uses a unified piece of machinery under the hood to handle filenames. Every command behaves uniformly with respect to filenames. The way in which commands work with filenames is as follows.

If you explicitly name real files on the command line, Mercurial works with exactly those files, as you would expect.

$ hg add COPYING README examples/simple.py

When you provide a directory name, Mercurial will interpret this as operate on every file in this directory and its subdirectories. Mercurial traverses the files and subdirectories in a directory in alphabetical order. When it encounters a subdirectory, it will traverse that subdirectory before continuing with the current directory.

$ hg status src
? src/main.py
? src/watcher/_watcher.c
? src/watcher/watcher.py
? src/xyzzy.txt

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.