【问题标题】:Bitbucket/Mercurial: Trouble pushing named branch (after closing earlier branch with same name)Bitbucket/Mercurial:推送命名分支时遇到问题(在关闭具有相同名称的早期分支之后)
【发布时间】:2013-08-02 21:46:55
【问题描述】:

我正在尝试将包含命名分支的变更集推送到托管在 Bitbucket 上的 Mercurial 存储库,我收到了 push creates a new remote head (did you forget to merge?) 错误。无论我是否将--new-branch 选项指定为hg push,都会发生这种情况。

(在这种情况下,Mercurial 文档建议“在推送之前进行拉取和合并”,但是当我运行 hg incoming 时,它会报告“未找到任何更改”,也就是说,Bitbucket 存储库中没有任何内容不在我的本地仓库)。

正如标题所暗示的那样,我的场景可能与我所看到的行为有关,我将在下面尝试解释:

我尝试推送到 Bitbucket 存储库的分支名称实际上与我之前成功推送但后来通过 hg commit --close-branch 关闭的分支名称相同,因为我错误地创建了它错误的父版本。

(为什么新分支名称必须与旧分支名称相同,这是一个很长的故事 - 但它确实如此。)

我不记得第一次推送分支有什么问题。我相信我使用hg push --new-branch 来做到这一点,但实际命令现在已经滚动到我的命令行历史缓冲区的顶部,所以我无法证明这一点。不过无论如何,--new-branch 选项这次并没有解决问题。

这是修订历史的图表:

   0         0. Baseline of production code
   |\
   1 \       1. Fixes to production code
   |  \
   2   \     2. More fixes to production code
  /|\  |
 3 | | |     3. Import new feature drop from offshore developer (*),
 | | | |        to named branch "drop1". (But I goofed! Parent
 | | | |        revision should have been r0.)
 | | | |
 4 | | |     4. "hg commit --close_branch" to prune the
   | | |        original "drop1" branch created in error.
   | | |
   | | 5     5. Import new feature drop again,
   | | |        this time with correct parent revision.
   | | |        Named branch via "branch -f drop1"
   | | |        (to shadow the name of the closed branch).
   |  \|
   |   6     6. Merge bug fixes from production into drop1
   |   |
   |   7     7. Fixes to drop1 code
   |
   8         8. Ongoing maintenance of production code

我已经能够将 r0 到 r4 提交到 Bitbucket 存储库,但尝试推送 r5(带或不带 --new-branch 选项)给了我:

abort: push creates new remote head 439d23090786 on branch 'drop1'!
(did you forget to merge? use push -f to force)

所以问题是:

  1. 除了使用 push -f 将 r5 放入 Bitbucket 存储库之外,我还有其他选择吗?
  2. 是否可能是 Bitbucket 的 Mercurial 版本不理解原始的“drop1”分支因 r4 的成功推送而关闭,从而导致 hg push --new-branch --rev 5 失败?

(*) 为什么离岸开发人员尚未直接使用 Mercurial 和 Bitbucket,而不是通过电子邮件将代码删除作为 zip 存档发送给我,这是一个太可怕的故事。]

【问题讨论】:

    标签: mercurial push bitbucket remote-branch


    【解决方案1】:

    您正在创建“drop1”的第二个头,即使另一个已关闭。只需使用 -f 作为错误消息状态。

    【讨论】:

    • 谢谢!我想“即使另一个关闭”的观察让我对此感到困惑。鉴于旧的已关闭,我的直觉是 Mercurial 会将新的视为与旧的不同。另外,我认为在将 r5 从我的工作存储库推送到我暂存变更集以推送到 Bitbucket 的存储库时,我应该看到这种麻烦。果然,我的命令历史显示我确实遇到了这样的麻烦,并通过 r6到我的暂存存储库中解决了这个问题。遗憾的是,拉入 Bitbucket 存储库是不可能的。 (对吧?或者有可能吗?)
    猜你喜欢
    • 2011-06-12
    • 2017-09-02
    • 2016-03-18
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多