自动向每个变更集添加一个包含新修订号的文件

发布于 2025-01-06 06:10:40 字数 754 浏览 0 评论 0原文

每当我提交时,我想将我正在创建的变更集的修订号保存在文件中。我还希望将该文件添加到同一变更集中。

请注意,工作目录的父目录的修订号不是我想要的,因为正在创建的变更集将具有更高的修订号。通常它只是父版本号 + 1,但如果自从我检查工作目录以来有人提交,它可能会更高。

更新:

我对这些信息感兴趣显然很奇怪,因为正如下面的评论所说,它是特定于存储库的,并且与其他人看到的不匹配。然而,我是唯一使用单个存储库的开发人员。我发现存储库修订号非常方便跟踪用于生成各种研究结果的代码。我可以看出它不太好,但它在这个特定场景中有效。

显然,我可以使用哈希值,但这在对话中更难记住和使用。如果我确实想使用哈希,我的问题仍然存在:如何获取正在提交的变更集的哈希。

相关:

mercurial - 我想要添加一些要在提交后运行的自定义代码似乎无法达到预期的结果。

这篇文章显然是相关的,但除非我错过了什么,否则它依赖于事实上,自当前用户上次签出以来,没有人提交到同一存储库。

我使用的是 Windows 7,TortoiseHG,最新版本。

Whenever I commit, I want to save in a file the revision number of the changeset that I'm creating. I also want that file to be added to the same changeset.

Note that the revision number of the parent of the working directory is not what I want because the changeset being created will have a higher revision number. Usually it's just the parent revision number + 1, but if someone committed since the time I checked out my working directory, it may be higher.

UPDATE:

It's obviously very strange that I'd be interested in this information, since as the comments below say, it's repo-specific and won't match what others see. However, I am the only developer, using a single repository. I find the repo revision numbers super convenient to keep track of what code was used to generated various research results. I can see how it's not great, but it works in this specific scenario.

Obviously, I could use the hash, but that's harder to remember and use in a conversation. If I did want to use the hash, my question would still remain: how to get the hash of the changeset that's being committed.

Related:

mercurial - I want to add some custom code to be run after commit seems to be unable to achieve the desired outcome.

This article is clearly relevant, but unless I miss something, it relies on the fact that nobody committed to the same repository since the last checkout by the current user.

I'm under Windows 7, TortoiseHG, latest version.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寂寞花火° 2025-01-13 06:10:40

您可能可以将其放在那里:

TIP=$(hg id --num --rev tip)
NEXT=$(($TIP + 1))

但请记住,这些数字几乎完全没有意义。当其他人克隆该存储库时,修订号可能会发生变化。只有节点 ID 在您查找它们的存储库之外才有意义。

You can probably just put this in there:

TIP=$(hg id --num --rev tip)
NEXT=$(($TIP + 1))

but please do keep in mind that those numbers are almost entirely meaningless. When someone else clones that repository the revision numbers can change. Only the nodeids have any meaning outside the repository in which you looked them up.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文