[英]How can I limit the size of a Mercurial log?
When I run Mercurial's "hg log" command from a terminal window, the results often fall off the screen, forcing me to scroll up to the top.当我从终端 window 运行 Mercurial 的“hg log”命令时,结果经常从屏幕上掉下来,迫使我向上滚动到顶部。 As a result, I created a template to reduce the verboseness and format of the log:因此,我创建了一个模板来减少日志的冗长性和格式:
[alias]
slog = log --template '{rev}:{node|short} {desc|firstline} ({author})\n'
However, I'd like to improve this even further by either a) limiting the size of the "slog" to just the last 10 commits or b) using a command like "hg slog ##", where "##" would be the number of logs shown in the results.但是,我想通过以下方式进一步改进这一点结果中显示的日志数。
Any thoughts on how to achieve either A or B?关于如何实现 A 或 B 的任何想法?
You could define your alias to do only a fixed limit in this way:您可以通过这种方式定义您的别名以仅执行固定限制:
slog = log --limit 10 --template "{rev}:{node|short} {desc|firstline} ({author})\n"
Or, you could put --limit
on the end so that you can pass a number to it, as arguments to an alias will be appended to the end:或者,您可以将--limit
放在末尾,以便您可以将一个数字传递给它,因为 arguments 将附加到别名的末尾:
slog = log --template "{rev}:{node|short} {desc|firstline} ({author})\n" --limit
The above could be called like this for the last 10 changesets:对于最后 10 个变更集,可以像这样调用上述代码:
hg slog 10
You should also be able to define the parameterized version in this way, but it doesn't seem to be property expanding the $1
:您还应该能够以这种方式定义参数化版本,但它似乎不是扩展$1
的属性:
slog = log --limit $1 --template "{rev}:{node|short} {desc|firstline} ({author})\n"
#I had to use shell execute to make it expand:
#slog = !hg log --limit $1 --template "{rev}:{node|short} {desc|firstline} ({author})\n"
To get last 10 changeset:要获取最后 10 个变更集:
hg log -l10
Alternative solution:替代解决方案:
Configure autopager plugin in the .hgrc
file.在.hgrc
文件中配置autopager 插件。
The end result is similar to already mentioned solution最终结果类似于已经提到的解决方案
hg log | less
If you're using a *nix environment, this allows you to scroll back through log history at your leisure:如果您使用的是 *nix 环境,这允许您在闲暇时回滚日志历史记录:
hg log | less
or according to your preference:或根据您的喜好:
hg log | more
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.