如何在 DVCS 中跨分支移动错误修复?

发布于 2024-11-24 08:01:31 字数 1484 浏览 1 评论 0原文

如果我们发现某些分支中的错误,我们会修复它(检查图片上的版本)。但我们也有兴趣将此修复移至版本和主要开发分支:

a-->b-->c              (Old release)
|    
A-->B-->C-->D           (Main release)
    |
    1-->2-->bugfix-->4  (New release)

svn记住svn:merge属性(来自svn 1.6,2009) )哪个修订版合并到哪个分支。因此,下次如果您合并修订区域,则先前合并的修订将从合并补丁中跳过。

如何应对现代 DVCS?

我需要制作普通补丁并将其应用到每个分支,还是 DVCS 提供一些帮助?

注意:我不能将New分支合并到Main,因为之前的变更集也会移动到Main分支。

变基也是不可能的,因为许多开发人员都发布了新版本。

我对命名分支模式和多存储库模式的回答很感兴趣。

PS. Andy 建议找到 bug 影响的所有分支的共同父级,对其进行更新,对 bug 进行修复,并将修复移至受影响的分支。

通过更新到旧的变更集并进行更改,您可以创建新的分支。我建议创建命名分支(将其命名为 bugID),以便稍后您可以轻松返回到它。

在寻找我们有兴趣修复错误的所有分支的共同父级时存在问题。

第一个解决方案(建议Andy)是使用$ hg/git/bzr Should并仔细检查所有受影响文件的输出。这涉及到首先修复一些最新变更集的错误,然后再用责备发现哪些变更集引入了错误。然后您需要变基修复(修补)公共父变更集。

另一个解决方案是使用 $ hg/git/bzr bisect (您也可以手动执行更新以查找引入错误的第一个修订版)。这可能是一个广泛但更真实的解决方案,因为允许将错误修复填充到存在错误的任何分支。

我认为最好先找到第一个BAD变更集,然后修复错误,而不是先修复错误,然后找到第一个BAD变更集(除非你已经知道如何做)修复错误)。引入差异也可以帮助理解它发生的原因。

PPS。有了错误,就可以清楚哪个分支受影响,以允许对任何受影响的分支进行合并更改。

如果问如何将功能从开发分支向后移植到发布分支,就会出现有趣的问题。正如您所看到的,您必须从发布分支之前的变更集开始提交功能变更集。但是当你开发功能时,你可能不知道哪里需要向后移植功能。使用 svn:merge VCS 会为您记住所有向后移植。 DVCS 怎么样?

If we discover bug in some branche we fix it (check New release on picture). But also we interesting in moving this fix to Old release and Main development branch:

a-->b-->c              (Old release)
|    
A-->B-->C-->D           (Main release)
    |
    1-->2-->bugfix-->4  (New release)

svn remember in svn:merge properties (from svn 1.6, 2009) which revision merged to which branches. So next time if you merge region of revisions previously merged revisions was skipped from merge patch.

How deal with modern DVCS?

I need make plain patch and apply it to each branches or there are exist some help from DVCS?

Note: I can not just merge New branche to Main as previous changesets move also to Main branche.

Rebase also not possible as New release come to many developers.

I interesting in answer for named braches schema and for multirepository schema.

PS. Andy suggest find common parent to all branches for which bug have affect, update to it, apply fix to the bug and move fix to affected branches.

By updating to old changeset and making changes you create new branch. I recommend create named branch (name it as bugID), so later you can easy back to it.

There are problem on finding common parent to all branches in which we have interest to fix bug.

First solution (that suggest Andy) is using $ hg/git/bzr blame and carefully check output for all affected files. This involve first fix bug on some newest changeset before you find with blame what changeset introduce a bug. Then you need rebase fix (patch) to common parent changeset.

Another solution is using $ hg/git/bzr bisect (you can also manually perform updates to find first revision in which bug introduced). This can be expansive but more true solution as allow populate bugfix to any branches in which bug present.

I think it is better first find first BAD changeset and then fix a bug, instead of first fix a bug and then find first BAD changeset (except case when you already know how fix bug). Also having a diff that introduce can help in understanding why it occur.

PPS. With bugs it is clear which branch effected to allow merge changes to any effected branch.

Interesting question come if ask how backport feature from development branch to release branch. As you can see you must commit feature changesets starting with changeset that before release branch. But when you develop feature you can don't know where you need backport feature. With svn:merge VCS remember for you all backports. How about DVCS?

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

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

发布评论

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

评论(3

栀梦 2024-12-01 08:01:34

您可以在要修复的每个受影响的分支上gitcherry-pick bugfix。不过,这将为每个分支上的修复生成一​​个新的提交 ID。

You could git cherry-pick bugfix on each affected branch that you want to fix. This would generate a new commit id for the fix on each branch, though.

蓝咒 2024-12-01 08:01:34

这就是为什么人们为每个功能或错误修复创建单独的分支。那么唯一的技巧是确保当您创建分支时,它是从排除您不希望包含在您打算合并回的每个分支中的任何提交的点开始的。如果您忘记了,您可以在进行任何合并之前将其重新设置为该点。如果您直到将其合并回新版本分支(如示例所示)之后才发现它,那么最好的选择可能是挑选,尽管如果您过于频繁地使用它,这可能会使将来的合并变得非常困难。

This why people make separate branches for each feature or bug fix. Then the only trick is to make sure when you create the branch, it is from a point that excludes any commits you wouldn't want included in every branch you intend to merge back into. If you forget, you can just rebase it to that point before doing any merges. If you don't catch it until after it's merged back into your new release branch as shown in your example, the best option is probably cherry picking, although that can make future merges very difficult if you use it too often.

恏ㄋ傷疤忘ㄋ疼 2024-12-01 08:01:33

您可以:

  1. 找到共同的父母。 感谢 Novelocrat 的这一步。
    git merge-basebranch1branch2branch3...

  2. 检查公共父项
    git checkout A

  3. 创建新分支来修复错误
    git checkout -b bugFix

  4. 进行错误修复并将其提交到 bugFix 分支

  5. 签出需要错误修复的分支
    git checkoutbranchToApplyFixTo

  6. 将 bugFix 合并到分支中
    git merge bugFix

You could:

  1. Find common parent. Thanks to Novelocrat for this step.
    git merge-base branch1 branch2 branch3 ...

  2. Checkout the common parent
    git checkout A

  3. create new branch to fix bugs on
    git checkout -b bugFix

  4. Make bug fixes and commit them to bugFix branch

  5. Checkout branch that needs the bug fix
    git checkout branchToApplyFixTo

  6. Merge the bugFix into the branch
    git merge bugFix

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文