如何获取分支中的 Mercurial 提交序列号

发布于 2025-01-06 18:30:09 字数 135 浏览 2 评论 0原文

我想检索提交订单号,仅计算特定分支(主)的提交。 由于分支“master”在每台机器/存储库上都是相同的,那么这将允许我: 1. 无论存储库如何,都具有相同的编号 2. 在版本字符串中使用该数字。

那么,有没有什么办法可以实现这一点呢?

I want to retrieve commit order number, counting ONLY commits of specific branch (master).
As a branch "master" is the same on each machine/repo, then this will allow me to:
1. Have the same number regardless of the repository
2. Use this number in a version string.

So, is there any way to accomplish this?

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

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

发布评论

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

评论(2

┈┾☆殇 2025-01-13 18:30:09

hg log -b master --template "." | wc -m 例如

输出分支中当前变更集的数量

hg log -b master --template "." | wc -m for example

Output current amount of changesets in branch

櫻之舞 2025-01-13 18:30:09

即使您将自己限制在一个命名分支上,您的想法也不会起作用。正如 Ry4an 所提到的,问题在于该分支上的变更集的顺序是由 hg pushhg pull 的顺序决定的。因此,您很容易会遇到这样的情况:

@    branch: master, changeset: 5:f5b6808f2f04, summary: merge
|\
| o  branch: master, changeset: 4:2b7bdcc98a88, summary: mmm
| |
o |  branch: master, changeset: 3:6b60342a01a6, summary: mm
|/
o  branch: master, changeset: 2:f39fa3fa1aaf, summary: m
|
o  branch: master, changeset: 1:4dd5e8ae6481, summary: create master
|
o  branch: default, changeset: 0:68b4eb1ca123, summary: a

在一个存储库中,但

@    branch: master, changeset: 5:f5b6808f2f04, summary: merge
|\
| o  branch: master, changeset: 4:6b60342a01a6, summary: mm
| |
o |  branch: master, changeset: 3:2b7bdcc98a88, summary: mmm
|/
o  branch: master, changeset: 2:f39fa3fa1aaf, summary: m
|
o  branch: master, changeset: 1:4dd5e8ae6481, summary: create master
|
o  branch: default, changeset: 0:68b4eb1ca123, summary: a

在另一个存储库中。请注意 mmmmm 变更集如何在两个存储库中交换。

只有当两个存储库中的分支具有相同的头时,您才能谈论每个存储库中的“分支相同”。如果是这种情况,那么,正如 Lazy 所建议的,简单的操作

hg log -b master --template "." | wc -m

将在两个存储库中给出相同的计数。

Your idea wont work, even though you limit yourself to a single named branch. As mentioned by Ry4an, the problem is that the order of changesets on that branch is determined by the order of hg push and hg pull. So you can easily end up with a situation where you have:

@    branch: master, changeset: 5:f5b6808f2f04, summary: merge
|\
| o  branch: master, changeset: 4:2b7bdcc98a88, summary: mmm
| |
o |  branch: master, changeset: 3:6b60342a01a6, summary: mm
|/
o  branch: master, changeset: 2:f39fa3fa1aaf, summary: m
|
o  branch: master, changeset: 1:4dd5e8ae6481, summary: create master
|
o  branch: default, changeset: 0:68b4eb1ca123, summary: a

in one repository, but

@    branch: master, changeset: 5:f5b6808f2f04, summary: merge
|\
| o  branch: master, changeset: 4:6b60342a01a6, summary: mm
| |
o |  branch: master, changeset: 3:2b7bdcc98a88, summary: mmm
|/
o  branch: master, changeset: 2:f39fa3fa1aaf, summary: m
|
o  branch: master, changeset: 1:4dd5e8ae6481, summary: create master
|
o  branch: default, changeset: 0:68b4eb1ca123, summary: a

in another. Note how the mm and mmm changesets are swapped in the two repositories.

It is only if the branch has the same heads in both repositories that you can talk about the "branch being the same" in each repository. If that is the case, then, as suggested by Lazy, a simple

hg log -b master --template "." | wc -m

will give the same count in both repositories.

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