如何使"hg log --verbose"在多行上显示文件? [英] How to make 'hg log --verbose' show files on multiple lines?

查看:68
本文介绍了如何使"hg log --verbose"在多行上显示文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,变更集中所有更改的文件都在同一行上,这使得它们很容易跳过一两个,而且很难阅读.

By default all files changed in a changeset are on the same line, which makes them very easily to skip one or two, and hard to read.

如何使每个文件单独显示在一行上?

How to make each file show on its own separate line?

推荐答案

查看有关已更改的文件信息的真实方法是使用hg status.这显示了在修订版100中修改的文件:

The real way to see information about changed files is to use hg status. This shows the files that were modified in revision 100:

$ hg status -c 100

但是,如果您还希望获得日志消息,那么hg log当然是一个自然的起点.不幸的是,没有内置开关会使它每行显示一个文件.

But if you want to have the log messages as well, then hg log is of course a natural starting point. Unfortunately there is no built-in switch that will make it display one file per line.

但是,hg log的输出由模板系统,您可以为此编写自己的样式.默认样式为此处,您可以自定义执行所需的操作通过更改

However, the output of hg log is controlled by a template system and you can write your own styles for it. The default style is here and you can customize to do what you want by changing

file = ' {file}'

file = '{file}\n'

然后将新样式另存为my-default.style并添加

Then save the new style as my-default.style and add

[ui]
style = ~/path/to/my-default.style

到您的配置文件.这样每行可以给您一个文件,甚至在文件名中有空格时也可以使用.

to your configuration file. This gives you one file per line and it even works when there are spaces in your file names.

我知道一个问题:您在hg log输出中失去了颜色.事实证明,水星在这里作弊!它实际上并没有使用我在生成日志输出时显示给您的默认模板.它根本不使用任何模板系统,它只是使用直接代码生成输出,因为这更快.问题在于颜色扩展名仅适用于硬编码模板.当您切换到自定义模板并由此调用模板引擎时,就会丢失颜色输出.

I'm aware of one problem: you lose colors in the hg log output. It turns out that Mercurial is cheating here! It doesn't actually use the default template I showed you when generating log output. It doesn't use any template system at all, it just generates the output using direct code since this is faster. The problem is that the color extension only work with the hard-coded template. When you switch to a custom template and thereby invoke the template engine, you lose the color output.

但是,您可以通过将 ANSI转义码直接插入模板中来恢复颜色(在类似Unix的系统上) ).更改

However, you can recover the colors by inserting the ANSI escape codes directly into your template (on Unix-like systems). Changing

changeset = 'changeset:   {rev}:{node|short}\n{branches}...

changeset = '\033[33mchangeset:   {rev}:{node|short}\033[0m\n{branches}...

可以解决问题,并为变更集硬编码黄色标题行.同时调整changeset_verbosechangeset_quiet行,您将获得带有自己模板的彩色输出.

does the trick and hard-codes a yellow header line for the changeset. Adjust the changeset_verbose and changeset_quiet lines as well and you'll have colored output with your own template.

这篇关于如何使"hg log --verbose"在多行上显示文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆