有没有比在 Mercurial 中提取当前修订哈希更好的方法
hg log -l1|grep changeset|cut -d: -f3
?
我的 webapp 部署脚本的一部分使用其唯一的修订哈希“标记”上传的应用程序 tarball。
尝试:
hg id -i
例子:
$ hg id -i
adc56745e928
hg --debug id -i
This will output the long hash, with a plus if there are uncommitted changes.
You can use --template with the parent command, I use this to get the long hash:
hg parent --template '{node}'
总结答案及其响应,这似乎是打印当前版本的唯一(非短格式)标识符的最佳方式:
hg log -l 1 --template '{node}\n' -r .
hg log -l 1 --template '{node|short}\n'
请参阅文档、“模板基础知识”和以下段落。
如果需要简洁性(正如问题所暗示的那样) ,由于存在的最具体的非 DEPRECATED 命令--template
只能打印修订信息:
hg log -l 1 -b . -T '{rev}:{node|short}\n'
或者对于独特的长形式哈希:
hg log -l 1 -r . -T '{node}\n'
-b .
或branch(.)
(分支名称的点)表示当前工作目录分支,-r .
表示当前工作目录修订版,记录在hg help revsets
和中hg help revisions
。
如果使用 TortoiseHg,请右键单击工作台中的修订行并选择“复制哈希”(根据文档)。
正如其他人指出的那样,不要使用log -l
.
用于hg log -r .
获取详细信息,而不是使用hg id
其输出受限且不支持模板。您还可以创建一个小别名here = log -r .
并使用hg here
. 如果您只想要哈希使用hg log -r . --template '{node}\n'
.