tags:

views:

588

answers:

3

How can I examine a changeset in mercurial without looking up its parent? In mercurial, what's the equivalent of

git show HEAD^

Git-show gives the changeset metadata and the diff as well.

+3  A: 

I think you want hg export cset.

tonfa
+1  A: 

You should also take a look at the parentrevspec extension to enable a more Git-like syntax for specifying revisions.

Martin Geisler
+3  A: 

Your question has two parts. First, how to get the metadata and diff for a changeset all at once:

hg log --patch --rev tip

You can shorten the options:

hg log -pr tip

The second part of the question is how to say "the parent changeset of X" without looking it up. For that you can use the parentrevspec extension Martin mentioned.

Once you enable the extension you can do:

hg log -pr tip^

You could add an alias to your ~/.hgrc file if you don't want to retrain your fingers from git's command:

[alias]
show = log -pr

Then you could use:

hg show tip^
Steve Losh
Without parentrevspec he could just do "-r -2" to get the changeset before tip, right?
Ry4an
Yes, that's true. That doesn't work for something like 'hg show mytag ^' though, right?
Steve Losh
In general, for this case, `hg export` is preferred (it lists full commit message, etc.).
tonfa
Preferred by who? If you want the full commit message you can add `--verbose`/`-v` to the log command. `log`'s output is much more human readable (the date and node/parent IDs are in a friendlier format) and it supports `--color`, unlike `export`.
Steve Losh