发生哈希冲突时如何按名称更新到分支?

How to update to a branch by name when there's a hash collision?

所以我的同事刚刚中了哈希彩票。我们按照约定 b##### 为我们解决的每张工单创建一个功能分支,其中 ##### 是问题编号。

问题在于,当他尝试通过 hg up branch(b29477) 更新到那个分支(在它存在之前)时,他没有说分支不存在,而是 default

事实证明 branch(b29477) 实际上 returns 括号内的事物的分支名称(而不是像我想的那样强制 Mercurial 将括号内的事物评估为分支名称! ), 碰巧有一个以 b29477 开头的变更集是默认的,所以不是说分支不存在,而是把他带到了默认的顶端!

现在我们可以通过选择不同的分支名称来解决这个问题,但我想知道是否有任何方法可以hg update <branch_name_and_dont_interpret_this_as_anything_else>


顺便说一句,hg log 谎言了它的 --branch 参数的作用。它说:

-b --branch BRANCH [+]   show changesets within the given named branch

但这根本不是真的。继续 运行 它的散列。例如,

hg log --branch eea844fb

它会显示结果。如果您仔细阅读文档,您会发现它实际上与以下内容相同:

hg log -r 'branch(eea844fb)'

试试这个:

hg update -r "branch('literal:b29477')"

来自 Mercurial 帮助页面:

branch(string or set)

All changesets belonging to the given branch or the branches of the given changesets.

If string starts with re:, the remainder of the name is treated as a regular expression. To match a branch that actually starts with re:, use the prefix literal:.

这意味着如果您使用 literal 前缀,则您指定的是 stringstring 不是 set

正如文字所说,如果您指定一个变更集,Mercurial 将显示:

the branches of the given changesets