带有文件状态的 Mercurial 日志格式
我想知道,如何以这种格式返回为提交添加/修改/删除的文件:
<modifier> file
<modifier> path/to/a/file
<modifier> path/to/another/file
在 git 中,我这样做:“git show --pretty =”format:“--name-status commitish”并获取:
D file
A path/to/a/file
M path/to/another/file
对于Mercurial 我不知道如何使用模板来做到这一点。我有一个样式文件:
changeset = "{file_mods}{file_adds}{file_dels}"
file_add = "A {file_add}\n"
file_mod = "M {file_mod}\n"
file_del = "D {file_del}\n"
通过这种样式和命令“hg log -r commitish --style ~/.hgstyle”,我几乎得到了我想要的:
M path/to/another/file
A path/to/a/file
D file
mercurial 仍然存在一个问题 - 文件是未按良好顺序排序。
如何在 Mercurial 上获得与 git 命令相同的结果(使用修饰符并正确排序)?
I was wondering, how do I return files added/modified/deleted for a commit in such a format:
<modifier> file
<modifier> path/to/a/file
<modifier> path/to/another/file
In git I do this: "git show --pretty="format:" --name-status commitish" and get:
D file
A path/to/a/file
M path/to/another/file
For mercurial I can't figure out how to do it with templates. I have a style file:
changeset = "{file_mods}{file_adds}{file_dels}"
file_add = "A {file_add}\n"
file_mod = "M {file_mod}\n"
file_del = "D {file_del}\n"
and with this style and command "hg log -r commitish --style ~/.hgstyle" I get almost what I want:
M path/to/another/file
A path/to/a/file
D file
There is still one issue with mercurial - files are not sorted in good order.
How do I get the same result as on git command (with modifiers and sorted correctly) on mercurial?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个:
Try this:
没有直接使用模板引擎的方法,但您可以尝试:
hg log --style ~/.hgstyle -r; | sort -k2
这将对第二列数据(即文件名)的日志命令的输出进行排序。
There is no direct way using the templating engine, but you could try:
hg log --style ~/.hgstyle -r <rev> | sort -k2
This will sort the output of the log command on the second column of data (i.e. the file names).
也许我没有理解正确,但是如果你想先删除,然后添加,最后修改,只需更改样式文件的第一行:
你也可以添加一个表格(
\t
)而不是如果你想更接近 Git 的外观,请加一个空格:Maybe I didn't understood correctly, but if you want deletion first, then addition and finally modifications, symply change the first line of your style file :
You can also add a tabulation (
\t
) instead of a space if you want to be closer to the Git look :将其添加到您的
.hgrc
文件中它将打印格式整齐的输出,如下所示(2 是版本号):
Add this to your
.hgrc
fileIt'll print a neatly formatted output like this (2 is the rev number):