Mercurial: diffs in a particular changeset?
Asked Answered
T

4

54

This is almost exactly a duplicate of Examining a single changeset in Mercurial, and without doubt a duplicate of another question I can't find on SO through Google alone.

I'm looking back through a Mercurial repo, and I want to see what exactly changed between two revisions (let's say 2580 and 2581):

hg log -v -r 2581 

gives me all the files that changed.

How can I also see the diffs of these files?

Thanks.

Triumphant answered 21/3, 2011 at 10:54 Comment(2)
just change the -v to a -p -- see my answer below.Gilbertine
Related: https://mcmap.net/q/340014/-examining-a-changeset-in-hgFurther
G
77

Revision 2580 isn't necessasrily the parent revision of 2581. It's easy to check if it is, of course, but easier yet is to just do:

hg log -p -r 2581

That compares 2581 to its (first) parent revision no matter what it is, and most clearly encompasses the answer to the question "what the hell did 2581 do?"

Gilbertine answered 21/3, 2011 at 14:28 Comment(2)
You could also just use hg diff -c 2581 for that.Geter
Wait a minute, doesn't the -p option mean "show patch"?Clemmie
A
6

Try hg diff -r 2580 -r 2581.

Anuria answered 21/3, 2011 at 11:3 Comment(0)
M
6
hg diff -r 2580 -r 2581

This is a wrong example. The revision 2580 can be in another branch and you get diff between two branches.

Use

hg log -p -r 2581

or hg diff -c 2581

The difference between them in the first lines. Hg log also show information about changeset (parent, author, date, ...)

I prefer second variant hg diff -c ... because it can store to patch files.

hg diff -c 2581 > revision_2581.patch

Messenia answered 18/1, 2016 at 12:58 Comment(0)
S
1

Another solution is to use revset notation which IMO is a better solution as you can use it in more places consistently (ie you don't need to know about diff -c and log -p ).

hg diff -r 'last(ancestors(2581),2)'

Yes that is rather verbose compared to -c (for diff) and -p (for log).

However mercurial allows you to create revset aliases

In your .hgrc:

[revsetalias]

next(s) = descendants(s, 1)
prev(s) = last(ancestors(s),2)

Now you can do

hg diff -r 'prev(2581)'
hg log -r 'prev(2581)'
Slater answered 4/4, 2019 at 21:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.