在 Mercurial 中处理项目的两个版本的工作流程

发布于 2024-12-27 07:37:34 字数 496 浏览 0 评论 0原文

我有一个版本 1.0 的应用程序。我现在需要开始 2.0 版本的工作,但同时维护和修复 1.0 版本中的错误。

1.0 中的错误修复将合并到 2.0 版本中,但不会将任何新功能从 2.0 向后移植到 1.0 > 释放。

我了解分支的工作原理,但是我需要能够同时处理两个版本,因此在同一工作文件夹中的分支之间切换是不切实际的。我希望能够同时运行两个版本的代码。

能够同时使用命名分支处理同一应用程序的两个版本的典型设置或工作流程是什么?即使用一个文件夹中的一个分支和另一个文件夹中的另一个分支?

我是否只需将存储库克隆到版本 2.0 的新文件夹中,并将分支设置为 2.0 版本的分支?

我对 Mercurial 有点陌生,所以如果这听起来有点天真,请原谅我。

I have an application that is version 1.0. I now need to start work on version 2.0 but at the same time maintain and fix bugs in version 1.0.

Bug fixes from 1.0 will be merged into the 2.0 release but no new functionality will be backported from the 2.0 to 1.0 release.

I understand how branches work however I need to be able to work on both versions at the same time so switching between branches in the same working folder isn't practical. I want to be able to run both versions of the code at the same time.

What is a typical setup or workflow for being able to work on two versions of the same application using named branches at the same time? i.e. working with one branch in one folder and another branch in another folder?

Do I just clone the repository into a new folder for version 2.0 and set the branch to the one for the 2.0 release?

I'm a bit new to Mercurial so please forgive me if this sounds a bit naive.

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

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

发布评论

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

评论(1

半世晨晓 2025-01-03 07:37:34

我是否只需将存储库克隆到 2.0 版本的新文件夹中并将分支设置为 2.0 版本的分支?

是的,每个主要版本都有一个单独的克隆就可以了。但是,您应该将主要开发保留在default分支并使用为每个主要版本命名分支。让我介绍一下工作流程:

当您的版本 1.0 完成后,您

$ cd ~/src/foo
$ hg tag 1.0
$ hg push http://your-server/foo

就可以继续在该克隆中工作以实现版本 2.0。当您发现需要修复 1.0 中的错误时,您

$ cd ~/src
$ hg clone http://your-server/foo foo-1.x
$ cd foo-1.x
$ hg update 1.0
$ hg branch 1.x
$ hg commit -m "Starting 1.x branch"
# now fix the bug... left as an exercise to the reader :)
$ hg commit -m "Fixed issue123"
# do QA to test the bugfix, make more commits as necessary
$ hg tag 1.1
$ hg push --new-branch
# make a release

只需在第一次推送时才需要 --new-branch 标志。它告诉 Mercurial 您确实想在历史记录中创建一个新的永久分支。

您现在想要将错误修复拉入其他存储库:

$ cd ~/src/foo
$ hg pull http://your-server/foo
$ hg merge 1.x
$ hg commit -m "Merge with 1.1"

通过使用 1. 的命名分支。 x 系列,您始终可以使用 hg update 1.x 转到该分支上的最新变更集。将 1.x 视为一个“浮动标记”,它始终指向该分支上最尖端的变更集。

标准分支 wiki 页面中描述了此工作流程。

Do I just clone the repository into a new folder for version 2.0 and set the branch to the one for the 2.0 release?

Yes, a separate clone for each major release will just fine. However, you should keep your main development on the default branch and use named branches for each major release. Let me run through the workflow:

When your version 1.0 is done, you do

$ cd ~/src/foo
$ hg tag 1.0
$ hg push http://your-server/foo

and you can then continue working in that clone towards version 2.0. When you find that you need to fix a bug in 1.0, you do

$ cd ~/src
$ hg clone http://your-server/foo foo-1.x
$ cd foo-1.x
$ hg update 1.0
$ hg branch 1.x
$ hg commit -m "Starting 1.x branch"
# now fix the bug... left as an exercise to the reader :)
$ hg commit -m "Fixed issue123"
# do QA to test the bugfix, make more commits as necessary
$ hg tag 1.1
$ hg push --new-branch
# make a release

The --new-branch flag is only necessary the first time you push. It tells Mercurial that you really do want to create a new permanent branch in the history.

You now want to pull the bugfix into the other repository:

$ cd ~/src/foo
$ hg pull http://your-server/foo
$ hg merge 1.x
$ hg commit -m "Merge with 1.1"

By using a named branch for the 1.x series, you can always use hg update 1.x to go to the latest changeset on that branch. Think of 1.x as a "floating tag" that always point to the tip-most changeset on that branch.

This workflow is described in the standard branching wiki page.

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