gpt4 book ai didi

.net - 您将如何使用 DVCS(在我的例子中是 mercurial)来开发不同版本的 .NET 框架?

转载 作者:行者123 更新时间:2023-12-04 06:13:21 26 4
gpt4 key购买 nike

我正在为我们的 cms(在 asp.net webforms 上运行)编写某种新的管理仪表板。由于各种原因,我们的一些旧服务器只能处理 .NET 2.0,因此我必须为此重写使用 lambda 表达式等的代码。

我想知道您将如何使用像 mercurial 这样的 dvcs 来同时开发这两个版本。

我当前的代码库和 mercurial 存储库针对 .NET 3.5。我对 mercurial 比较陌生,我想我必须分支代码库?

任何最佳实践或教程?

最佳答案

是的,您可以为此使用 Mercurial。这是它的工作方式。

假设您当前的克隆名为 new-dot-net因为它
支持新的.Net 版本。你克隆它并调用它old-dot-net或类似的东西。这两个克隆现在完全相同
并且都针对 .Net 3.5。

现在小心地在 old-dot-net 中做些小改动为了使它
.Net 2.0 兼容。当您进行更改时,两个克隆将
开始发散:

new-dot-net: ... [a] --- [b]old-dot-net: ... [a] --- [b] --- [c] --- [d]

Here you made [c] and [d] changesets to add the .Net 2.0compatibility. Notice how the old-dot-net clone contains morechangesets than new-dot-net since it has the backwards compatibilitychanges that you dont want to see in new-dot-net. As you continueworking, it is important to think of this: net-dot-net will containa subset of the changesets in old-dot-net. The changes flow fromnew-dot-net to old-dot-net, but never in the opposite direction.

Let's say you make a new change in new-dot-net. You make the changein new-dot-net and the situation now looks like this:

new-dot-net: ... [a] --- [b] --- [x]old-dot-net: ... [a] --- [b] --- [c] --- [d]

You now want to back-port the change to old-dot-net as well, youchange to old-dot-net and pull from net-dot-net:

% cd old-dot-net
% hg pull ../new-dot-net

这将创建一个 new headold-dot-net :
                             [x]                            /old-dot-net: ... [a] --- [b] --- [c] --- [d]

since the [x] changeset has [b] as it's parent changeset. You nowhave multiple heads and have to merge to reduce the number ofheads. By merging you create a new changeset which is your way ofsaying "this is how [x] and [d] should be combined". If the [x]changeset only touches code which is not also touched in [c] and[d], then the merge should just work. Otherwise you'll be presentedwith a merge tool and have to resolve the conflict. You commit themerge as chageset [e]:

                             [x] --------------.                            /                   \old-dot-net: ... [a] --- [b] --- [c] --- [d] --- [e]

And you're done -- you have now incorporated the [x] change intoyour .Net 2.0 compatible code.

You repeat this every time there has been a change in new-dot-net.Let's say that more features are added:

new-dot-net: ... [a] --- [b] --- [x] --- [y] --- [z]

After pulling them into old-dot-net you get

                             [x] --------------.---- [y] --- [z]                            /                   \old-dot-net: ... [a] --- [b] --- [c] --- [d] --- [e]

And you now merge [e] and [z]:

                             [x] --------------.---- [y] --- [z]                            /                   \               \old-dot-net: ... [a] --- [b] --- [c] --- [d] --- [e] ----------- [f]

The important parts to remember are these:

  • make any new features in new-dot-net.
  • pull changes into old-dot-net
  • never push from old-dot-net to new-dot-net.

Should you at some point find that a change in new-dot-net is notneeded in old-dot-net, then you still need to pull it in and mergeit. But you will then do a dummy merge. If the heads are [w] and[g], and you want keep [g], then do

% HGMERGE=true hg merge -y
% hg revert --all --rev g
% hg commit -m 'Dummy merge with y.'

trick是在不关心结果的情况下进行合并,
然后还原所有更改,并将未更改的工作副本提交为
合并。这样你就告诉全世界“ [w][g][g] ",即您丢弃 [w] 中的更改。新 new-dot-net 中所做的更改之后 [w]然后可以像这样合并
普通的。

关于.net - 您将如何使用 DVCS(在我的例子中是 mercurial)来开发不同版本的 .NET 框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/919685/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com