I have a file tracked in Mercurial. I can see its history with hg log
. How can I see the diffs between its most recent version, and the last checked-in changeset?

- 5,637
- 32
- 48

- 89,519
- 86
- 202
- 261
-
Isn't "most recent version" the same as "last checked-in changeset version"? – Lasse V. Karlsen Nov 11 '10 at 12:45
3 Answers
hg diff -r <first_revision_number>:<other_revision_number> filename
that will do it
e.g hg diff -r 0:1 default.aspx
hope it helps

- 5,536
- 3
- 25
- 44

- 8,198
- 1
- 31
- 35
-
Interesting: Not finding this in `hg diff -h --verbose`. Really should be there. – CodeLurker Aug 29 '17 at 16:36
If you know the revision numbers, then what PaulStack said is correct.
If you explicitly want to know the difference between the current tip of the branch, and it's previous, you can use shortcuts. Of course, if the file hasn't changed, the diff won't show anything useful.
hg diff -r -1:. filename
The -1
says previous changeset on this branch. the '.
' means the current changeset. You can use -2
, -3
etc, but once you hit a merge point, it gets a little more interesting. (reference: http://hgtip.com/tips/beginner/2009-10-05-shortcuts-for-specifying-revisions/)
If what you want is the outstanding changes in your workspace, then it's merely hg diff filename.
A few useful places for HG newbies is http://hgtip.com.
The HG definitive guide at http://hgbook.red-bean.com/.
A stackoverflow like site that's more HG specific is the Kiln support site. http://kiln.stackexchange.com. Kiln is built on top of HG, and uses a modified TortoiseHG client, so most of the questions and answers there are informative. They will also answer questions even if you aren't a user.
-
1This is (I think) a lot more likely to be helpful than the marked answer. – podperson Nov 13 '15 at 00:53
-
Interesting: Not finding this in `hg diff -h --verbose`. Really should be there. – CodeLurker Aug 29 '17 at 16:36
-
The -1 revision shortcut is being deprecated. Is there another method to do this? – Ecnassianer Dec 11 '19 at 01:27
-
there is also de ^
syntax for the parent revision, which in addition to .
(the parent of the working directory) make a useful combination:
show the diff between current checked out revision and its parent revision (this works around tip
and -1
limitations)
hg diff -r .^:.

- 2,488
- 1
- 24
- 38