Useful Tips for Newcomers

Under some revision control systems, printing a diff for a single committed revision can be painful. For instance, with Subversion, to see what changed in revision 104654, you must type svn diff -r104653:104654. Mercurial eliminates the need to type the revision ID twice in this common case. For a plain diff, type hg export 104654. For a log message followed by a diff, type hg log -r104654 -p.

When you run hg status without any arguments, it prints the status of the entire tree, with paths relative to the root of the repository. This makes it tricky to copy a filename from the output of hg status into the command line. If you supply a file or directory name to hg status, it will print paths relative to your current location instead. So to get tree-wide status from hg status, with paths that are relative to your current directory and not the root of the repository, feed the output of hg root into hg status. You can easily do this as follows on a Unix-like system:

$ hg status `hg root`

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.