简体   繁体   中英

Can I get hg log to print the history in reverse order?

如果没有,这是git的功能吗?

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] , where BEGIN and END are revision identifiers.
Both BEGIN and END are optional.
If BEGIN is not specified, it defaults to revision number 0.
If END 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 of 9: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.

你试过了吗

hg log -r :

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 :

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.

Just in order to mention

Revset (long) version:

hg log -r "sort(all(),-date)"

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)"

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM