简体   繁体   English

如何限制 Mercurial 日志的大小?

[英]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.

相关问题 如何减小数组参数的大小? - How can I reduce the size of an array argument? 如何创建用于Mercurial的模板启动器项目? - How would I create a template starter project for use in Mercurial? 如何在NetBeans 7.1.1中为日志消息创建代码模板 - How can I create a code template in NetBeans 7.1.1 for a log message C ++如何改进这个模板元程序,以回馈包含大小的数组? - C++ How can I improve this bit of template meta-program to give back the array including the size? 我如何使用C ++ 11显式模板来减小二进制大小? - How can i use C++11 explicit templates to reduce binary size? 在带有模板的函数中传递未知大小的 std::Array。 如何更正此代码? - Passing unknown size std::Array in a function with template. How can I correct this code? 我可以根据内容为汞日志输出着色吗? - Can I color hg log output based on content? 为什么我不能使用QList :: size_type,因为我会使用std :: string :: size_type? (模板参数错误) - Why can't I use QList::size_type as I would std::string::size_type? (template parameter error) 模板函数如何“知道”作为模板参数给出的数组的大小? - How can a template function 'know' the size of the array given as template argument? 如何在Django模板中的表单中获取字段的长度,大小或数量? - How to I get the length or size or number of fields in a form in a django template?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM