在 Mercurial 中创建一个临时命名分支,然后将其从存在中删除

发布于 2024-12-15 17:55:46 字数 991 浏览 3 评论 0原文

我正在考虑在 TeamCity Visual Stuio 插件中添加“Mercurial 远程运行(个人构建)”功能。

自 v6.5 起,TeamCity 支持“远程运行分支触发器”,如果推送与 TeamCity 中的触发器匹配的命名分支,TeamCity 将运行该分支的个人构建。

这个想法是从当前分支(假设是默认分支)获取当前的传出变更集,并将它们移动到名为远程运行的临时命名分支。然后将其推送到 CI,以便触发个人构建,如果个人构建成功,则更改将移回原始分支,并删除远程运行分支。

我对此有几个问题:

  1. 这是否有意义?
  2. 我应该使用哪个扩展程序?我相信 MqExtension 可以满足我需要的一切,但是还有其他选择吗?
  3. 如果用户在远程运行期间提交其他更改,会发生什么情况? “临时分支”变更集如何合并回原始分支?

我当前的目标场景如下:在默认分支上工作时,用户添加了 3 个新修订。然后,他希望将这些更改作为 TeamCity 上的个人构建来运行,但他忘记将这些修订提交到专门命名的分支。相反,我的插件将接受这些传出的更改,并将它们放入指定的分支中。一旦个人构建成功,这些更改就会被放回原始(默认)分支,并推送到远程存储库。

像这样的事情:

[default] A---B---C---D

假设 BCD 是新修订版,我希望该工具执行以下操作:

[default] A
           \
            [remote-run] B---C---D

完成后,返回它到原始状态,即:

[default] A---B---C---D

编辑:我设法使用 Mq 将更改移动到另一个分支,这最终非常容易。不幸的是,我不知道如何恢复此更改:)

希望这是有道理的!

I'm toying with the idea of adding a "remote-run (personal build) for Mercurial" ability in the TeamCity Visual Stuio plugin.

Since v6.5, TeamCity supports a "remote run branch trigger", where if a named branch matching the trigger in TeamCity is pushed, TeamCity will run a personal build of that branch.

The idea is taking the current outgoing changeset(s) from the current branch (let's say default), and moving them to a temporary named branch called remote-run. This is then pushed to the CI, so the personal build gets triggered, and if the personal build is successful, changes are moved back to the original branch, and the remote-run branch is deleted.

I have a few questions regarding this:

  1. Does it even makes sense?
  2. Which extension should I use for this? I believe MqExtension does everything I would need, but are there alternatives?
  3. What would happen if the user commits additional changes during the remote run? How would the "temporary branch" changesets merge back into the original branch?

The scenario I'm currently targeting is as follows: while working on the default branch, user adds 3 new revisions. He then wants to run those changes as a personal build on TeamCity, but he forgot to commit those revisions to a specially named branch. Instead, my addin will take those outgoing changes, and put them in the named branch. Once the personal build succeeds, those changes are then placed back in the original (default) branch, and pushed to the remote repository.

Something like this:

[default] A---B---C---D

Assuming B, C and D are the new revisions, I want the tool to do:

[default] A
           \
            [remote-run] B---C---D

And after it's done, return it to the original state, i.e.:

[default] A---B---C---D

EDIT: I managed to move the changes to another branch with Mq, this ended up being very easy. Unfortunately, I have no idea how to revert this change :)

Hope this makes sense!

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

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

发布评论

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

评论(2

方圜几里 2024-12-22 17:55:46

成功构建后,您可以让 TeamCity 标记您的 VCS 根目录。在默认情况下标记每个成功的构建而不使用单独的分支可能不是更有意义吗?

我不确定您的任务背后的动机,您希望从哪些具体工作流程中受益?

关于第 3 项,无法保证自动合并回默认值。如果存在合并冲突,无论您在“个人构建”的构建配置中放入什么命令脚本,都需要它的帮助才能让您回到稳定状态 - 特别是“CI”。

抱歉,我在第一遍时无法提供更多帮助。

You can have TeamCity tag your VCS root upon successful build. Might it not make more sense to just tag each successful build on default, without the separate branch?

I'm not sure otherwise of the motive behind your mission, what specific workflow do you want to benefit from?

Regarding item 3, there is no way to guarantee an automated merge back into default. If there are merge conflicts, whatever command script you put into your build config for the "personal build" will require its hand holding to get you back into a stable state - not particularly "CI".

Sorry I can't help more on first pass.

む无字情书 2024-12-22 17:55:46

这正是“hg rebase”命令的用途。在您的情况下使用

hg rebase -s B -d A --detach

请确保您使用最新版本(最近的夜间版本)。最近修复了一个可能影响此指定情况的错误。
此外,必须启用“rebase”扩展才能使其工作。确保 ~/.hgrc (或 Mercurial.ini)文件中有以下行:

[extensions]
rebase = 

编辑: 看来我回答了一个相反的问题(如何删除本地分支)。要创建新的命名分支并将 B、C、D 修订版导入其中,您需要执行以下命令序列:

hg qimport -r tip:B       #Revisions B,C,D will be imported into mq
                          #(here B is revision id of the "B" commit)
hg qpop --all             #Unapply all patches
hg branch remote-run      #Create a new branch
hg qpush --all            #Push patches into the new branch
hg qfinish -a             #Transform applied patches to regular commits

That is exactly what 'hg rebase' command for. In your case use

hg rebase -s B -d A --detach

Make sure you use the latest version (latest night build). Recently a bug had been fixed that can affect this specified situation.
Also, 'rebase' extension must be enabled for this to work. Make sure yo have following line in ~/.hgrc (or mercurial.ini) file:

[extensions]
rebase = 

EDIT: It seems I answered an opposite question (how to remove a local branch). To create a new named branch and import B,C,D revisions into it you'll need following sequence of commands:

hg qimport -r tip:B       #Revisions B,C,D will be imported into mq
                          #(here B is revision id of the "B" commit)
hg qpop --all             #Unapply all patches
hg branch remote-run      #Create a new branch
hg qpush --all            #Push patches into the new branch
hg qfinish -a             #Transform applied patches to regular commits
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文