132

有没有比在 Mercurial 中提取当前修订哈希更好的方法

hg log -l1|grep changeset|cut -d: -f3

?

我的 webapp 部署脚本的一部分使用其唯一的修订哈希“标记”上传的应用程序 tarball。

4

8 回答 8

207

尝试:

hg id -i

例子:

$ hg id -i
adc56745e928
于 2010-03-21T04:25:51.537 回答
44
hg --debug id -i

This will output the long hash, with a plus if there are uncommitted changes.

于 2012-02-15T20:48:11.987 回答
24

You can use --template with the parent command, I use this to get the long hash:

hg parent --template '{node}'
于 2012-02-16T20:16:53.487 回答
17

总结答案及其响应,这似乎是打印当前版本的唯一(非短格式)标识符的最佳方式:

hg log -l 1 --template '{node}\n' -r .
于 2013-08-02T12:29:09.203 回答
9
hg log -l 1 --template '{node|short}\n'

请参阅文档、“模板基础知识”和以下段落。

于 2010-03-21T03:26:58.307 回答
5

如果需要简洁性(正如问题所暗示的那样) ,由于存在的最具体的非 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

请注意,如果存在未提交的合并.(点)仅显示工作组的两个父级的第一个父级。

于 2015-11-26T14:25:06.420 回答
3

如果使用 TortoiseHg,请右键单击工作台中的修订行并选择“复制哈希”(根据文档)。

在此处输入图像描述

于 2018-07-24T16:32:36.173 回答
3

正如其他人指出的那样,不要使用log -l.

用于hg log -r .获取详细信息,而不是使用hg id其输出受限且不支持模板。您还可以创建一个小别名here = log -r .并使用hg here. 如果您只想要哈希使用hg log -r . --template '{node}\n'.

于 2016-08-01T09:27:49.243 回答