hg-log
Show revision history from Mercurial repository
TLDR
Display the entire revision history of the repository
Display the revision history with an ASCII graph
Display the revision history with file names matching a specified pattern
Display the revision history, excluding file names that match a specified pattern
Display the log information for a specific revision
Display the revision history for a specific branch
Display the revision history for a specific date
Display revisions committed by a specific user
SYNOPSIS
hg log [OPTION]... [FILE]...
PARAMETERS
-r REV, --rev REV
Show changesets specified by a revision or revset (e.g., a branch name, tag, or specific hash). This is a powerful way to filter history.
-l N, --limit N
Limit the number of changesets displayed to the first N entries.
-u USER, --user USER
Show only changesets committed by the specified USER (can be a username or email address).
-d DATE, --date DATE
Show changesets committed on or after/before a specific DATE or within a date range (e.g., '2023-01-01 to 2023-01-31').
-k TEXT, --keyword TEXT
Show changesets whose commit message, author, or description contains the specified TEXT.
-m TEXT, --message TEXT
Show changesets whose commit message contains the specified TEXT.
-P, --patch
Include the patch (diff) for each changeset in the output. Useful for quickly seeing what changed.
-v, --verbose
Show more details, such as affected files, parents, and branches for each changeset.
-G, --graph
Draw an ASCII art revision graph alongside the changesets, illustrating branch and merge history.
-T TEMPLATE, --template TEMPLATE
Use a custom template string to format the output of each changeset, allowing for highly flexible display.
--follow
When applied to specific files, follow file history across copies and renames. Useful for understanding a file's full lineage.
--style STYLE
Use a named style definition for formatting the output, providing predefined templates.
--branch BRANCH
Show changesets belonging only to the specified BRANCH.
DESCRIPTION
The hg log command displays the complete revision history of a Mercurial repository, or a filtered subset of it. It is a fundamental tool for understanding changes over time, who made them, when, and what was changed. By default, hg log shows all changesets in the current branch, ordered from newest to oldest, including the changeset hash, author, date, and commit message. Users can apply various filters to narrow down the displayed history, such as by specific files, authors, dates, or messages. The command also supports advanced formatting options, allowing users to customize the output extensively for specific analysis needs. It's an essential utility for tracing bugs, reviewing code, and understanding project evolution.
CAVEATS
For very large repositories or histories, running hg log without specific filters (like --limit or --rev) can consume significant time and resources as it processes the entire history. The use of complex revsets or templates might require some familiarity with Mercurial's internal data structures and query language.
REVSETS
Revsets are Mercurial's powerful query language for selecting changesets. They allow users to specify complex conditions to filter history based on parent-child relationships, dates, authors, branches, and more. For example, hg log -r 'branch(default) and ancestors(.)' shows all changesets on the 'default' branch up to the current revision. Mastering revsets significantly enhances the utility of hg log.
CUSTOM TEMPLATES
The --template option allows users to define custom output formats using a mini-language. This can be used to extract specific information from each changeset (e.g., just the author and hash), or to format the log entries for integration with other tools. This flexibility makes hg log highly adaptable to various scripting and reporting needs beyond simple console viewing.
HISTORY
The hg log command has been a core component of Mercurial (hg) since its early days, designed to provide efficient and detailed revision history in a distributed version control environment. Its capabilities have evolved with Mercurial itself, particularly with the introduction and enhancement of revsets and flexible output templates, making it a powerful and indispensable tool for developers managing changes.