LinuxCommandLibrary

hg-log

Show revision history from Mercurial repository

TLDR

Display the entire revision history of the repository

$ hg log
copy

Display the revision history with an ASCII graph
$ hg log [[-G|--graph]]
copy

Display the revision history with file names matching a specified pattern
$ hg log [[-I|--include]] [pattern]
copy

Display the revision history, excluding file names that match a specified pattern
$ hg log [[-X|--exclude]] [pattern]
copy

Display the log information for a specific revision
$ hg log [[-r|--rev]] [revision]
copy

Display the revision history for a specific branch
$ hg log [[-b|--branch]] [branch]
copy

Display the revision history for a specific date
$ hg log [[-d|--date]] [date]
copy

Display revisions committed by a specific user
$ hg log [[-u|--user]] [user]
copy

SYNOPSIS

hg log [OPTION]... [FILE]...

PARAMETERS

-r, --rev REV[+]
    Show specified revision(s) or range(s), e.g., 'REV1:REV2' or 'tip'

-l, --limit NUM
    Limit number of changesets displayed

-p, --patch
    Show patch for each changeset (implies -g)

-g, --git
    Use git-style extended diff format

--branch BRANCH[+]
    Filter by branch name(s)

-u, --user USER[+]
    Filter by user(s)

-d, --date DATE
    Filter by date specifier, e.g., 'YYYY-MM-DD'

-k, --keyword TEXT[+]
    Filter by keywords in commit message

-f, --follow
    Follow history across file renames (deprecated)

-C, --copies
    Show copy/rename source file

-t, --template TEMPLATE
    Custom output using template

--color[=MODE]
    Enable colored output (always/auto/never)

DESCRIPTION

The hg log command is a core utility in Mercurial (hg), a distributed version control system. It outputs the history of changesets in the current repository or specified files, listing revisions chronologically from newest to oldest. Each entry typically includes the changeset hash, branch, tags, date, author, commit message summary, and file changes.

By default, it shows all revisions affecting the working directory. Powerful filtering options allow narrowing by revision range, branch, user, date, keywords, or files. Use -p to include full patches, -l to limit entries, or -r for specific revisions. It supports templating for custom output formats and recursion into subrepositories.

Ideal for reviewing project evolution, debugging issues, generating changelogs, or bisecting changes. Output is human-readable and script-friendly, often piped to grep or less. Note that Mercurial repositories must be initialized (hg init) or cloned for use.

CAVEATS

Requires a Mercurial repository; verbose output without limits; deprecated options like -f may change; large repos can be slow without -l or -r.

EXAMPLES

hg log -l 5: Last 5 changesets.
hg log -r 'ancestor(parent1, parent2)': Common ancestor.hg log -p file.txt: Patches for file changes.

FILESETS

Supports filesets for advanced filtering, e.g., hg log 'set:modified()' for modified files.

HISTORY

Introduced in Mercurial 0.9b (2005) by Matt Mackall; evolved with features like bookmarks (1.9, 2010), phases (2.1, 2012), and templating enhancements; remains stable core command.

SEE ALSO

git-log(1), bzr-log(1), hg-help(1)

Copied to clipboard