服务器端SVN分支重新集成
我正在开发一个平台,用于在我们的环境中自动化和集成功能分支步骤。
现在我知道重新集成分支的正确过程是:
- svn merge URL/trunk (在分支工作副本中与主干同步)
- svn update(在主干工作副本中)
- svn merge --reintegrate URL/branch(在主干工作副本中)
第一点是最容易出错的,因为可能会有一些冲突需要解决,所以它只是客户端。
但我会通过我的平台 GUI 在服务器上运行重新集成合并,显然是在检查确保分支与主干同步之后。 这可能吗?
I am developing a platform to automate and integrate feature branching steps in our environment.
Now I know that the right procedure to reintegrate a branch is:
- svn merge URL/trunk (in branchworking copy to synchronise with trunk)
- svn update (in trunk working copy)
- svn merge --reintegrate URL/branch (in trunk working copy)
Point one is the most error prone, because there could be some conflicts to be resolved, so it is only client side.
But I would run reintegrate merge on the server through my platform GUI, obviously after a check to ensure that the branch is synchronised with trunk. Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,让我检查一下场景 - 我猜你正在尝试将开发人员与主干完全隔离,这样就没有人直接提交到主干。 我假设你的平台自动创建这些分支,开发人员可以在某个时候说他们已经完成了分支并将其合并回来。因此代码遵循以下循环:
我实际上完全支持这个,如果这是您想要的工作方式,那就太好了。
我想不出它会彻底失败的任何原因,但您必须检查以下事项: 在
第1点是最重要的。 这意味着当重新集成发生时,它实际上必须是无操作。 如果您的 2.2 步骤中发生任何类型的合并,我想说您必须放弃提交并让开发人员再次从主干重新建立基础。 即使 svn 说合并成功并且没有冲突,你也不能相信它已经做了足够正确的事情,以至于解雇后就忘记了。 如果您要实现自动化,请保证开发人员提交的内容是被合并的内容,而不是某些自动生成的混合内容。
您可以通过查看合并的输出来检查合并是否“干净” - 如果任何文件被“合并”,则存在问题。 如果它们刚刚更新,那就没问题。
第 3 点很有趣,但始终是一个问题,即使在正常工作中也是如此。 在这种情况下,开发人员 A 会说他们已经完成了,重新调整他们的工作副本,然后花一些时间检查一切是否正常。 与此同时,开发者 B 偷偷更新了 trunk。 开发人员 A 认为一切正常并重新集成。 然而,开发人员 B 所做的更改意味着代码会变得混乱,即使它没有触及开发人员 A 修改的任何文件。由于开发人员 A 是最后提交的,因此他们受到指责。
假设是,如果开发人员 A 包含了开发人员 B 的更改,那么他就会发现问题。 您的平台有机会发现这种情况(例如,如果 svn-merginfo 说有可以提交到分支的主干修订,那么它不是最新的)。 然而,我也警告不要在没有必要的情况下创建一个永恒的合并周期。 也许可以向开发人员发出警告,表明他们重新建立基础后已经进行了提交,但无论如何都允许他们继续进行。
最后一点:我在上面提到过使用 svn-mergeinfo。 您不能依赖于此来假设重新集成合并就可以了。 如果这样做,在进行检查和提交合并之间就会出现竞争条件 - 有人可能会同时介入。 您仍然需要检查实际合并命令的输出以了解到底发生了什么。
如果多个开发人员尝试同时重新集成,还要注意这种情况。 如果您每次都签出一个新的工作副本,则可以拥有任意数量的工作副本,但提交很可能会因旧的“文件已过期”类型错误而失败。 在这些情况下,重新集成将再次失败,您必须让开发人员重新建立他们的分支。
总而言之我喜欢它。 其中有相当多的复杂性,但归根结底,这就是这种系统的重点 - 它处理复杂的事情,因此开发人员不必这样做。 他们所要做的就是不断重新调整分支机构,直到系统让他们成功重新整合。
Ok, let me just check the scenario - I guess you're trying to isolate the developers from the trunk entirely so that no-one commits directly to trunk. I assume your platform automatically creates these branches and the developers can at some point say that they're finished with the branch and have it merged back in. So the code follows the cycle:
I'm actually all for this, if it's the way you want to work, great.
I can't think of any reason why it would fail outright, but you must check the following things:
Point 1 is the most important. This means that when re-integration occurs, it must effectively be a no-op. If any sort of merging happens in your 2.2 step, I'd say you must throw the commit away and make the developer re-base from trunk again. Even if svn says the merge says is successful and without conflicts, you just can't trust it to have done the right thing enough to fire and forget. If you're going to automate, guarantee that what the developer committed is what gets merged, not some auto-generated hybrid.
You can check if the merge was 'clean' just by looking at the output of the merge - if any of files were 'merged' then there's a problem. If they were just updated, then you're ok.
Point 3 is interesting but is always a problem, even in normal working. In this scenario, developer A would say they're finished, re-base their working copy then spend a while checking that everything works ok. In the mean time, developer B sneaks in an update to trunk. Developer A decides that everything is ok and re-integrates. However, changes made by developer B mean that code goes screwy even though it didn't touch any files modified by dev A. Since dev A was the last to commit, they get blamed.
The assumption is that if dev A had included dev B's changes, then he would have spotted the problem. Your platform has the opportunity to spot this situation (for example, if svn-merginfo says there are trunk revisions that can be committed to the branch, then it's not up to date). However I'd also caution against creating an eternal merge cycle where it's not necessary. Perhaps give the developers a warning that a commit has been made since they re-based, but allow them to go ahead anyway.
One last note: I mentioned using svn-mergeinfo above. You cant rely on this to assume that a re-integrate merge will be ok. If you do, there'll be a race condition between making the check and committing the merge - someone could have got in in the mean time. You still need to check the output of the actual merge command to see what really happened.
Also be aware of the situation if multiple devs try to re-integrate at the same time. If you check out a fresh working copy each time, you can have as many as you like, but the commits may well fail with the old "file out of date" type error. In these situations, again, the re-integration will fail and you'll have to get the developer to re-base their branches.
All in all I like it. There's a fair bit of complication in there, but at the end of the day, that's the point of this kind of system - it deals with the complex stuff so the devs don't have to. All they have to do is keep re-basing their branches until the system lets them re-integrate successfully.