Mercurial: diffs in a particular changeset?

34,153

Solution 1

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?"

Solution 2

Try hg diff -r 2580 -r 2581.

Solution 3

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

Solution 4

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)'
Share:
34,153
AP257
Author by

AP257

Updated on July 09, 2022

Comments

  • AP257
    AP257 almost 2 years

    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.

  • Ringding
    Ringding over 13 years
    You could also just use hg diff -c 2581 for that.
  • Saulo Silva
    Saulo Silva over 7 years
    Wait a minute, doesn't the -p option mean "show patch"?