Mercurial: Creating a diff of two commits

25,913

Solution 1

I came upon this page while trying to figure this very thing out. I found my solution via hg help diff .

hg diff -r <rev> -r <rev> worked for my needs (diffing between two tags)

Solution 2

An external diff

The extdiff extension will allow you to use your preferred external diff tool. In my case I use meld so day to day I run this type of command

hg meld -r <rev1> -r <rev2>

First enable the extdiff extension in the extensions section (I also have shelve & record enabled)

[extensions]
shelve =
record =
hgext.extdiff =

Then add this section ...

[extdiff]
cmd = meld
cmd.meld = /usr/bin/meld

to your .hgrc file. Obviously replace meld with the command used to launch your preferred tool

Solution 3

Export? One patch-file per changeset, something like

hg export --output %r.patch --rev A --rev B

Share:
25,913
DerKuchen
Author by

DerKuchen

Updated on October 11, 2022

Comments

  • DerKuchen
    DerKuchen over 1 year

    Is there a way to get the changes of two commits with mercurial? The second commit is not directly after the first one, there are some other ones between them.

    I tried

    hg diff [some params] --change xxxxx --change yyyyy > file.patch
    

    but that only includes the last changeset.

    If there is no way to achieve this with hg, is there maybe a tool to combine patches?