hg log (with examples)
1: Display the entire revision history of the repository
hg log
MOTIVATION: This use case is helpful when you want to see a comprehensive record of all the commits made in the repository. It allows you to understand the changes and progress of the project over time.
EXPLANATION:
The hg log
command is used to display the revision history of the repository. By default, it shows the commit message, revision number, author, date, and summary of all commits in reverse chronological order.
EXAMPLE OUTPUT:
changeset: 1:abcd1234efgh
user: John Doe <johndoe@example.com>
date: Tue Jan 01 00:00:00 2022 -0500
summary: Initial commit
changeset: 2:1234abcd5678
user: Jane Smith <janesmith@example.com>
date: Wed Jan 02 00:00:00 2022 -0500
summary: Added feature A
changeset: 3:5678efgh9012
user: John Doe <johndoe@example.com>
date: Thu Jan 03 00:00:00 2022 -0500
summary: Fixed bug B
2: Display the revision history with an ASCII graph
hg log --graph
MOTIVATION: If you want to visualize the branching and merging in your repository, using the ASCII graph can help. It provides a clear representation of the commit paths and their relationships.
EXPLANATION:
The --graph
flag is used with the hg log
command to generate an ASCII graph representation of the revision history. It shows the commits and their relationships using lines and nodes.
EXAMPLE OUTPUT:
@ changeset: 3:5678efgh9012
| user: John Doe <johndoe@example.com>
| date: Thu Jan 03 00:00:00 2022 -0500
| summary: Fixed bug B
|
| o changeset: 2:1234abcd5678
|/ user: Jane Smith <janesmith@example.com>
| date: Wed Jan 02 00:00:00 2022 -0500
| summary: Added feature A
|
o changeset: 1:abcd1234efgh
user: John Doe <johndoe@example.com>
date: Tue Jan 01 00:00:00 2022 -0500
summary: Initial commit
3: Display the revision history with file names matching a specified pattern
hg log --include pattern
MOTIVATION:
When you want to focus on changes related to specific files or file patterns, using the --include
option is helpful. It allows you to filter the revision history and only display commits that modified the specified files.
EXPLANATION:
The --include
option is used with the hg log
command to specify a pattern that the file names should match. Only commits that modified files matching the pattern will be included in the output.
EXAMPLE OUTPUT:
changeset: 2:1234abcd5678
user: Jane Smith <janesmith@example.com>
date: Wed Jan 02 00:00:00 2022 -0500
summary: Added feature A
files: src/file1.py, src/file2.py
changeset: 3:5678efgh9012
user: John Doe <johndoe@example.com>
date: Thu Jan 03 00:00:00 2022 -0500
summary: Fixed bug B
files: src/file1.py, src/file3.py
4: Display the revision history, excluding file names that match a specified pattern
hg log --exclude pattern
MOTIVATION:
In some cases, you may want to exclude certain files or file patterns from the revision history. The --exclude
option allows you to filter out commits that modified the specified files, providing a cleaner view of the revision history.
EXPLANATION:
The --exclude
option is used with the hg log
command to specify a pattern that the file names should not match. Commits that modified files matching the pattern will be excluded from the output.
EXAMPLE OUTPUT:
changeset: 1:abcd1234efgh
user: John Doe <johndoe@example.com>
date: Tue Jan 01 00:00:00 2022 -0500
summary: Initial commit
changeset: 3:5678efgh9012
user: John Doe <johndoe@example.com>
date: Thu Jan 03 00:00:00 2022 -0500
summary: Fixed bug B
5: Display the log information for a specific revision
hg log --rev revision
MOTIVATION:
When you want to view the details of a specific commit, such as its author, date, and changes, using the --rev
option is useful. It allows you to navigate to a specific revision in the revision history.
EXPLANATION:
The --rev
option is used with the hg log
command to specify the revision(s) to display. You can provide a revision number, a revision identifier (changeset hash), or a revision expression.
EXAMPLE OUTPUT:
changeset: 2:1234abcd5678
user: Jane Smith <janesmith@example.com>
date: Wed Jan 02 00:00:00 2022 -0500
summary: Added feature A
6: Display the revision history for a specific branch
hg log --branch branch
MOTIVATION:
If your repository has multiple branches, you may want to focus on the revision history of a specific branch. The --branch
option allows you to filter the log output and only display the commits made on the specified branch.
EXPLANATION:
The --branch
option is used with the hg log
command to specify the branch for which to display the revision history. Only commits made on the specified branch will be included in the output.
EXAMPLE OUTPUT:
changeset: 2:1234abcd5678
user: Jane Smith <janesmith@example.com>
date: Wed Jan 02 00:00:00 2022 -0500
summary: Added feature A
changeset: 3:5678efgh9012
user: John Doe <johndoe@example.com>
date: Thu Jan 03 00:00:00 2022 -0500
summary: Fixed bug B
7: Display the revision history for a specific date
hg log --date date
MOTIVATION:
If you need to track the changes made on a specific date, the --date
option can be handy. It allows you to filter the log output and only display the commits made on the specified date.
EXPLANATION:
The --date
option is used with the hg log
command to specify the date for which to display the revision history. Only commits made on the specified date will be included in the output.
EXAMPLE OUTPUT:
changeset: 1:abcd1234efgh
user: John Doe <johndoe@example.com>
date: Tue Jan 01 00:00:00 2022 -0500
summary: Initial commit
8: Display revisions committed by a specific user
hg log --user user
MOTIVATION:
If you want to examine the contributions of a specific user in the repository, using the --user
option can help. It allows you to filter the revision history and only display commits made by the specified user.
EXPLANATION:
The --user
option is used with the hg log
command to specify the user for which to display the revision history. Only commits made by the specified user will be included in the output.
EXAMPLE OUTPUT:
changeset: 1:abcd1234efgh
user: John Doe <johndoe@example.com>
date: Tue Jan 01 00:00:00 2022 -0500
summary: Initial commit
changeset: 3:5678efgh9012
user: John Doe <johndoe@example.com>
date: Thu Jan 03 00:00:00 2022 -0500
summary: Fixed bug B