# Mercurial tips

I’m using mercurial for my work (I’m a git user since years) since quite recently and I’m solving regularery a series of problems, here is a compilation of small tips and tricks I’ve came across.

## adding pagination (== “pipe through less”) to an alias

Problem:

You’ve written this wonderful alias (to hg log for e.g) but the output isn’t send to a pager (“| less) like hg log and that sucks.

Solution:

If you are on a modern mercurial installer : just remove the pager plugin, it’s not needed anymore and it will auto guess when to do that.

Assuming you have the Pager extension installed, you need to add your alias to the paged commands like this:

[pager]
attend = annotate, cat, diff, export, glog, log, qdiff, \$MY_ALIAS

And voilà!

## Display the diff of the current commit

So you are lost inside you zillion of #mercurial commits and just want to see the diff of the current one? Worry not and add this wonderful alias!

[alias]
current = log -p -r . -T '{node}\n'

## Moving relatively in mercurial history

So you are lost in some commits and looking at hg log all the time to know which id to give to hg update? Here are some commands to help you with that.

The evolve extension provides hg next and hg prev to move the previous and the next changeset (commit) relative to the current one.

The get to the first parent public changeset while you are in draft one, you can add this alias:

[alias]
pub = up 'max(::. and public())'

The get to the last changeset (the head) of the current changegroup you can add this alias:

[alias]
last = up 'max(.::)'

Thx JordiGH and Denis for the hints :)