Mercurial:查找存在提交的所有分支

发布于 2024-12-01 13:01:47 字数 137 浏览 1 评论 0原文

我有几个分支和一个 ID X 的提交,我希望 Mercurial 返回该提交所在的分支列表。

Mercurial 已经在每次提交中存储了有关分支的信息,但仅限于引入该提交的分支的信息。如果您将该提交合并到其他分支,提交仍将仅存储原始分支名称。

I have a few branches and a commit with ID X, I want Mercurial to return me a list of branches where that commit exists.

Mercurial already stores information about branch in every commit, but only about a branch in which that commit was introduced. If you merge that commit into some other branch, commit will still store only original branch name.

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

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

发布评论

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

评论(1

美煞众生 2024-12-08 13:01:47

我认为你可以用这个公式得到你想要的

hg log -r 'descendants(X) and head()'

head() 包括所有命名分支头,所以即使分支的尖端已合并到另一个命名分支中,它仍然会与此一起列出公式。

如果您只想显示分支名称,则可能需要对 hg log 命令使用 --template '{branches}\n' 指令。如果每个命名分支有多个头,您最终可能会使用 uniq 或类似的。

编辑:描述这将做什么

A----B----C----D----E  Branch: default (E is a merge of F into D)
      \    \    \ /
       \    \    F     Branch B1 (closed)
        \    G-----H   Branch B2
         \    \
          \    I       Branch B2
           J           Branch B3

如果您执行 hg log -r 'descendants(C) and head()',您应该得到 E、F、H 和 I。

  • E:你得到E,因为“默认”是一个分支头,即使它有一个特殊的名称。
  • F 出现是因为即使你合并到 E 中,它仍然是一个 head(),所以它出现在这个列表中
  • G 不是一个头,虽然它确实包含 C
  • H 是一个头,并且显然是从 G 分支的 C I 的后代
  • ,也是一个头,并且显然包含 C
  • J< /em> 是一个头,但没有 C 作为祖先

I think you could get what you want with this formula

hg log -r 'descendants(X) and head()'

head() includes all named branch heads, so even if the tip of a branch has been merged into another named branch, it will still be listed with this formula.

If you only want to show branch names, you will probably want to use the --template '{branches}\n' directive for the hg log command. If you have more than one head per named branch, you may end up using uniq or similar.

EDIT: To describe what this will do

A----B----C----D----E  Branch: default (E is a merge of F into D)
      \    \    \ /
       \    \    F     Branch B1 (closed)
        \    G-----H   Branch B2
         \    \
          \    I       Branch B2
           J           Branch B3

If you execute hg log -r 'descendants(C) and head()', you should get E, F, H and I.

  • E: You get E, because 'default' is a branch head, even though it has a special name.
  • F comes up because even though you merged into E, it's still a head(), so it shows up on this list
  • G is not a head, although it does contain C
  • H is a head and clearly a descendant of C
  • I branched from G, is also a head, and clearly contains C
  • J is a head, but does not have C as an ancestor
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文