Huu*_*uze 8 version-control mercurial templates
当我从终端窗口运行Mercurial的"hg log"命令时,结果通常会从屏幕上掉下来,迫使我向上滚动到顶部.因此,我创建了一个模板来减少日志的冗长和格式:
[alias]
slog = log --template '{rev}:{node|short} {desc|firstline} ({author})\n'
Run Code Online (Sandbox Code Playgroud)
但是,我想通过以下方式进一步改进:a)将"slog"的大小限制为最后10次提交,或者b)使用"hg slog ##"之类的命令,其中"##"将是结果中显示的日志数.
有关如何实现A或B的任何想法?
Joe*_*ant 12
您可以通过以下方式定义别名以仅执行固定限制:
slog = log --limit 10 --template "{rev}:{node|short} {desc|firstline} ({author})\n"
Run Code Online (Sandbox Code Playgroud)
或者,您可以放在--limit最后,以便您可以传递一个数字,因为别名的参数将附加到结尾:
slog = log --template "{rev}:{node|short} {desc|firstline} ({author})\n" --limit
Run Code Online (Sandbox Code Playgroud)
对于最后10个变更集,可以像这样调用上面的内容:
hg slog 10
Run Code Online (Sandbox Code Playgroud)
您还应该能够以这种方式定义参数化版本,但它似乎不是扩展的属性$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"
Run Code Online (Sandbox Code Playgroud)
要获得最后10个变更集:
hg log -l10
替代解决方案:在文件中
配置autopager插件.hgrc.
最终结果类似于已经提到的解决方案
hg log | less
Run Code Online (Sandbox Code Playgroud)