简体   繁体   English

我可以获取hg日志以反向顺序打印历史记录吗?

[英]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 : YGL的答案是正确的日志,请参阅此主题

The hint from "hg help log" might be: “hg help log”中的提示可能是:
"If no revision range is specified, the default is tip:0". “如果未指定修订范围,则默认为tip:0”。 Combine this with the knowlegde from " hg help multirevs ". 将其与“ hg help multirevs ”中的knowlegde相结合 That is: 那是:

hg log -r :

multirevs : multirevs

When Mercurial accepts more than one revision, they may be specified individually, or provided as a topologically continuous range, separated by the " : " character. 当Mercurial接受多个修订时,它们可以单独指定,也可以作为拓扑连续范围提供,以“ : ”字符分隔。

The syntax of range notation is [BEGIN]:[END] , where BEGIN and END are revision identifiers. 范围表示法的语法是[BEGIN]:[END] ,其中BEGINEND是修订标识符。
Both BEGIN and END are optional. BEGINEND都是可选的。
If BEGIN is not specified, it defaults to revision number 0. 如果未指定BEGIN ,则默认为版本号0。
If END is not specified, it defaults to the tip. 如果未指定END ,则默认为提示。
The range ":" thus means "all revisions". 范围“:”因此意味着“所有修订”。

If BEGIN is greater than END , revisions are treated in reverse order. 如果BEGIN大于END ,则以相反的顺序处理修订。

A range acts as a closed interval. 范围充当闭合间隔。 This means that a range of 3:5 gives 3, 4 and 5. 这意味着3:5的范围给出3,4和5。
Similarly, a range of 9:6 gives 9, 8, 7, and 6. 类似地, 9:6的范围给出9,8,7和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 . 注意:如果你想对Graphlog (行为类似于(子集)普通log命令的glog做同样的glog ,除了它还使用log左边的ASCII字符打印表示修订历史的图表。),你将需要一个补丁

I should warn you that it will be very slow for large graphs, particularly 0:tip . 我应该警告你,对于大型图形来说,它会非常慢,尤其是0:tip
See patch 1 and patch 2 . 请参见补丁1补丁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): 如果您想将反向顺序设置为默认值,请将此行添加到您的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 nad2000的答案的另一种方法是在~/.hgrc添加一个别名

[alias]
logr = log -r :

Now calling hg logr displays the logs in reverse order. 现在调用hg logr会以相反的顺序显示日志。 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. 不幸的是,正如VonC所指出的,无法为glog定义相同类型的别名,因为hg glog -r :不会以相反的顺序显示日志。

Just in order to mention 只是为了提一下

Revset (long) version: Revset(长)版本:

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

I'm surprised nobody mentioned reverse() yet. 我很惊讶没人提到反向()。 Maybe it's a newer hg feature? 也许这是一个更新的hg功能?

hg log -r "reverse(all())"

Sure, you could go with tip:0 as well. 当然,你也可以使用小费:0。 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: 不确定这是否已经改变或者我做错了什么,但我从Mercurial获得反向时间顺序日志,如下所示:

hg log -r tip:0

I usually limit them to the most recent log entries too, using -l : 我通常使用-l将它们限制为最新的日志条目:

hg log -r tip:0 -l 3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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