如何获取分支中的 Mercurial 提交序列号
我想检索提交订单号,仅计算特定分支(主)的提交。 由于分支“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
hg log -b master --template "." | wc -m
例如输出分支中当前变更集的数量
hg log -b master --template "." | wc -m
for exampleOutput current amount of changesets in branch
即使您将自己限制在一个命名分支上,您的想法也不会起作用。正如 Ry4an 所提到的,问题在于该分支上的变更集的顺序是由
hg push
和hg pull
的顺序决定的。因此,您很容易会遇到这样的情况:在一个存储库中,但
在另一个存储库中。请注意
mm
和mmm
变更集如何在两个存储库中交换。只有当两个存储库中的分支具有相同的头时,您才能谈论每个存储库中的“分支相同”。如果是这种情况,那么,正如 Lazy 所建议的,简单的操作
将在两个存储库中给出相同的计数。
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
andhg pull
. So you can easily end up with a situation where you have:in one repository, but
in another. Note how the
mm
andmmm
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
will give the same count in both repositories.