我希望我的“hg h”(一个 hg 日志别名的输出)在历史/日志的上下文中显示我当前工作的修订版。
在我的 .hgrc 上,我有以下内容:
[alias]
h = log --template "{rev} {node|short} {date|shortdate} | [{author|user}] {desc|strip|firstline} :: {tags}\n"
这是一个示例输出:
$ hg h
1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit ::
但是如果我更新到修订版 0,输出仍然相同:
$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg h
1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit ::
所需输出的示例是:
$ hg h
1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit :: [working]
注意:[working] 不是标签,只是我的工作修订版,我更新的那个。
另一个例子可能是:
$ hg h
1 f130b4194c90 2011-07-21 | | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 |X| [slashfoo] initial commit ::
我使用 hgbook 关于“自定义 Mercurial 的输出”的条目自定义了我的“hg h”输出http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html
我想做的替代方案可能是:
hg h -G
以便@ 表示当前的工作修订版 hg id
想知道我是什么版本hg parents
想知道我是什么版本,还有一些额外的信息 但只有替代 #1 向我展示了上下文,但 hg log -G 和别名比我想要的输出更不“紧凑”。
这是替代方案 #1 的输出示例
$ hg h -G
o 1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
|
@ 0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit ::
这个问题类似于How can I find my working revision in mercurial但我希望在上下文中以紧凑的方式(即没有 -G)
最佳答案
hg log --rev $(hg id -i | sed 's/.$//')
关于version-control - 如何在 mercurial 的 "hg log"上显示当前的工作修订版?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6780853/