Mercurial:同时设置多个变更?

发布于 2024-10-11 22:51:38 字数 317 浏览 4 评论 0原文

以前,当我使用 perforce 时,只要代码不影响相同的文件,我就可以通过一次打开多个更改集来同时处理多个错误。

变更集 1:


  • A.txt
  • B.txt
  • C.txt

变更集 2:


  • D.txt
  • E.txt
  • F.txt

我可以将变更集 2 提交到存储库,而不提交变更集 1(因为它仍在进行中)

这对于 Mercurial 来说可能吗?除了将每个文件作为单独的提交之外?

Before, when I was using perforce, I could work on multiple bugs at once as long as the code did not affect the same files, by having multiple change sets open at once.

Changeset 1:


  • A.txt
  • B.txt
  • C.txt

Changeset 2:


  • D.txt
  • E.txt
  • F.txt

I could submit changeset 2 to the repository without submitting changeset 1 (because it's still in progress)

Is this possible with Mercurial? other than doing each file as a separate commit?

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

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

发布评论

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

评论(5

拔了角的鹿 2024-10-18 22:51:38

您始终可以执行以下操作:hg commit D.txt E.txt F.txt 只提交那些不会提交 A.txt、B.txt 和 C.txt 的文件。使用 -I 选项进行提交可以让您使用模式执行这些操作,例如,如果它们位于公共目录中:hg commit -I 'dir1/**'

You can always just do: hg commit D.txt E.txt F.txt to commit just those files which will leave A.txt, B.txt, and C.txt uncommited. Using the -I option to commit lets you do those with patterns if they're, for example, in a common directory: hg commit -I 'dir1/**'

海风掠过北极光 2024-10-18 22:51:38

您可以有两个独立的分支(工作副本),并在其中进行一个更改,在另一个中进行另一个更改。这是一种方法。

另一种方法是使用 Mercurial 队列。如果变更集彼此没有依赖关系,您可以使用 qpush --move 来更改变更集的顺序,这样您就可以使用 qfinish 来“提交”第一个变更集准备好。

You can have two separate branches (working copies) and make one change in and the other in the other. That's one way.

Another is to use Mercurial Queues. You can use qpush --move to change the order of changesets if they have no dependencies on one another, so you can then use qfinish to 'commit' the first changeset that's ready.

明媚如初 2024-10-18 22:51:38

实际上,您并没有在 Mercurial 中“打开”变更集。

您要么已提交更改,要么尚未提交。

但是,您可以拥有多个包含未提交更改的文件,并且只提交其中的几个。甚至可以提交部分文件、块,而不是整个文件。

如果我要按照您的要求进行操作,我只需在第一个克隆的本地进行另一个克隆,然后在两个不同的工作文件夹中处理两个不同的修复程序。然后我就可以自由地组合两者(本地推/拉)、推送到服务器等。

You don't actually hold changesets "open" in Mercurial.

Either you've committed your changes, or you haven't.

You can, however, have multiple files with uncommitted changes, and only commit a few of them. It is even possible to commit parts of files, chunks, instead of the whole file.

If I was to do what you're asking I would simply make another clone locally from my first one, and work on the two different fixes in two different working folders. Then I have all the freedom I need to combine the two (push/pull locally), push to the server, etc.

我一直都在从未离去 2024-10-18 22:51:38

在 Mercurial 中,在本地完成克隆是一种廉价的操作。只需克隆您正在处理的每件事的存储库即可。一切准备就绪后推送回主存储库:

hg clone http://project project
hg clone project project-bugfix   // uses hardlinks and is inexpensive.
hg clone project project-feature
<edit bugfix and feature as needed>

但请记住,默认推送位置是从中克隆的项目,因此您需要编辑“项目”克隆的 .hg\hgrc 的默认推送路径,或者确保完成后从“project-bugfix”和“project-feature”hg Push http://project

In Mercurial, cloning is a cheap operation when done locally. Just clone the repository for each thing you are working on. Push back to the main repository as each thing is ready:

hg clone http://project project
hg clone project project-bugfix   // uses hardlinks and is inexpensive.
hg clone project project-feature
<edit bugfix and feature as needed>

But remember that the default push location is the project cloned from, so you'll either need to edit .hg\hgrc's default push path for the "project" clones, or make sure to hg push http://project from "project-bugfix" and "project-feature" when complete.

若无相欠,怎会相见 2024-10-18 22:51:38

即使您的修改涉及同一个文件,您也可以选择要包含的内容(逐块)。您只需激活 record 扩展(默认安装但未激活)。

要激活记录扩展,请将其放入 .hgrc[extensions] 部分:

[extensions]
hgext.record=

然后进行提交,将 hg commit 替换为 hg 记录。我们假设您的示例更改集包含一个 G.txt 文件,该文件对两个更改集都有更改。承诺:

hg record D.txt E.txt F.txt G.txt

回答问题,例如:

2 hunks, 6 lines changed
examine changes to 'D.txt'? [Ynsfdaq?] f     # f for full file (help with ?)
... skipped file E and F
6 hunks, 35 lines changed
examine changes to 'G.txt'? [Ynsfdaq?] y
@@ ... (patch hunk here)
record change 6/16 to 'G.txt'? [Ynsfdaq?] y   # y to include the hunk, n to skip

Even if your modifications touches the same file you can select what to include (hunk by hunk). You just have to activate the record extension (it's installed by not activated by default).

To activate the record extension, put this in the [extensions] section of your .hgrc:

[extensions]
hgext.record=

Then to commit, replace hg commit by hg record. Let's assume your example change sets with a G.txt file that have changes for both change sets. Commit with:

hg record D.txt E.txt F.txt G.txt

Answer questions, for example:

2 hunks, 6 lines changed
examine changes to 'D.txt'? [Ynsfdaq?] f     # f for full file (help with ?)
... skipped file E and F
6 hunks, 35 lines changed
examine changes to 'G.txt'? [Ynsfdaq?] y
@@ ... (patch hunk here)
record change 6/16 to 'G.txt'? [Ynsfdaq?] y   # y to include the hunk, n to skip
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文