If not, is this a feature that git has?
-
It already does print in reverse, you need reverse-reverse (or forward). Hence some of the answers give the normal order (reversed). – ctrl-alt-delor Mar 15 '15 at 12:51
-
It there a way to get it to work with `-G` (graph)? I was using `hg log | tac` but the `/`s and `\`s come out the wrong way (and there is no colour). I only need it for use with `-G` – ctrl-alt-delor Mar 15 '15 at 12:53
7 Answers
YGL's answer is the right one for log, see this thread:
The hint from "hg help log" might be:
"If no revision range is specified, the default is tip:0". Combine this with the knowlegde from "hg help multirevs". That is:
hg log -r :
multirevs:
When Mercurial accepts more than one revision, they may be specified individually, or provided as a topologically continuous range, separated by the "
:
" character.The syntax of range notation is
[BEGIN]:[END]
, whereBEGIN
andEND
are revision identifiers.
BothBEGIN
andEND
are optional.
IfBEGIN
is not specified, it defaults to revision number 0.
IfEND
is not specified, it defaults to the tip.
The range ":" thus means "all revisions".
If BEGIN
is greater than END
, revisions are treated in reverse order.
A range acts as a closed interval. This means that a range of
3:5
gives 3, 4 and 5.
Similarly, a range of9:6
gives 9, 8, 7, and 6.
Note: if you want to do the same with Graphlog (the glog
that behaves like (a subset of) the normal log
command except that it also prints a graph representing the revision history using ASCII characters to the left of the log
.), you will need a patch.
I should warn you that it will be very slow for large graphs, particularly
0:tip
.
See patch 1 and patch 2. I am working on improving that.
If you'd like to set reverse-order as a default, add this line to your hgrc (<repo>/.hg/hgrc, $HOME/.hgrc, /etc/mercurial/hgrc):
[defaults]
log = -r :

- 1,015
- 2
- 9
- 22

- 4,526
- 1
- 30
- 25
-
1I'm assuming that this changes the default behavior of hg log to show the history in reverse order. – Erik B Mar 09 '11 at 10:18
-
3I initially upvoted this, but now I realize that this won't work for me as it breaks the ability for hg log to show a single revision. That is, hg log now shows revisions in reverse. Good. However, hg log -r 25 won't show just changeset 25 - it will still show the entire list of changesets. – firebush Feb 06 '12 at 21:48
An alternative to nad2000's answer would be to simply add an alias in ~/.hgrc
[alias]
logr = log -r :
Now calling hg logr
displays the logs in reverse order. Unfortunately, as pointed out by VonC, the same type of alias cannot be defined for glog
, since hg glog -r :
does not display the logs in reverse order.

- 1,909
- 2
- 20
- 27
-
3+1 Adding an alias seems like a better idea than changing the default behavior. (@firebush explains why) – Erik B Apr 06 '13 at 12:10
Just in order to mention
Revset (long) version:
hg log -r "sort(all(),-date)"

- 94,711
- 9
- 78
- 110
-
This is really the correct answer. 'log -r :' doesn't work if you need a DAG log (::) instead of a chronological log (:). – Sergio Acosta Jan 14 '14 at 18:29
I'm surprised nobody mentioned reverse() yet. Maybe it's a newer hg feature?
hg log -r "reverse(all())"
Sure, you could go with tip:0 as well. I like reverse because I also often use it when mixed with ancestors.
hg log -r "reverse(::12345)"

- 14,252
- 13
- 80
- 114
Not sure if this has since changed or I’ve done something wrong, but I get reverse-chronological order logs from Mercurial like this:
hg log -r tip:0
I usually limit them to the most recent log entries too, using -l
:
hg log -r tip:0 -l 3

- 96,640
- 56
- 199
- 270