This question is not a duplicate of hg log - How to get the last 5 log entries? - it is easy to apply a limit. The problem is that the log output, when limited, does not appear to always be ordered descending by log date - the behavior changes with the addition of a revset.
For example, the simple log work "as expected" and it is displays the newest five log entries.
hg log -l5
However, when using a revset the result is the oldest nodes first (as observed without -l
); hence the following shows the oldest five entries which is not desired.
hg log -r "user('Me')" -l5
How can can hg log
, with a revset, be instructed to order by the log date descending ("as expected") so that the limit has a predictable1 and meaningful effect?
$ hg --version
Mercurial Distributed SCM (version 3.6.1)
1 I don't consider throwing random reverse
calls in a revset predictable, but if that is the "best" way..
There are a couple of options you have.
First, you can use
reverse()
in conjunction with your existing revset, e.g.:As a shorthand, you can also use
-f
or--follow
, which – when used in conjunction with-r
– will wrap the revision inreverse(...)
. Example:Or you can encode the limit in the changeset, e.g.:
Note that revset aliases can be useful to avoid having to type out revsets over and over. So, you can put something like this in your
.hgrc
:And then do: