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

标签 .net asp.net version-control mercurial dvcs

我正在为我们的 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.0 compatibility. Notice how the old-dot-net clone contains more changesets than new-dot-net since it has the backwards compatibility changes that you dont want to see in new-dot-net. As you continue working, it is important to think of this: net-dot-net will contain a subset of the changesets in old-dot-net. The changes flow from new-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 change in 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, you change 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 now have multiple heads and have to merge to reduce the number of heads. By merging you create a new changeset which is your way of saying "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 presented with a merge tool and have to resolve the conflict. You commit the merge as chageset [e]:

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

And you're done -- you have now incorporated the [x] change into your .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 not needed in old-dot-net, then you still need to pull it in and merge it. 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/

相关文章:

.net - 类库项目构建错误,引用损坏

.net - 在没有安装officebeeing的情况下读取excel文件

.net - 向 IoC 容器注册类型应该由谁负责?

asp.net - 授权失败时如何返回自定义 View 或 JSON,而不是显示用户名和密码对话框

c# - 如何向客户端发送多个文件以供下载

SVN不忽略文件

c# - 适用于 Windows Phone 的 Microsoft TPL 数据流

c# - 如何创建JObject的JArray?

version-control - 我的工具栏未在 API 级别 19 (Kitkat) 上显示,而在 API 级别 21 上显示

ruby-on-rails - 使用 Gerrit 部署 Ruby on Rails 数据库