Mercurial:同时设置多个变更?
以前,当我使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您始终可以执行以下操作:
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/**'
您可以有两个独立的分支(工作副本),并在其中进行一个更改,在另一个中进行另一个更改。这是一种方法。
另一种方法是使用 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 useqfinish
to 'commit' the first changeset that's ready.实际上,您并没有在 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.
在 Mercurial 中,在本地完成克隆是一种廉价的操作。只需克隆您正在处理的每件事的存储库即可。一切准备就绪后推送回主存储库:
但请记住,默认推送位置是从中克隆的项目,因此您需要编辑“项目”克隆的 .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:
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.即使您的修改涉及同一个文件,您也可以选择要包含的内容(逐块)。您只需激活
record
扩展(默认安装但未激活)。要激活记录扩展,请将其放入
.hgrc
的[extensions]
部分:然后进行提交,将
hg commit
替换为hg 记录
。我们假设您的示例更改集包含一个G.txt
文件,该文件对两个更改集都有更改。承诺:回答问题,例如:
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
:Then to commit, replace
hg commit
byhg record
. Let's assume your example change sets with aG.txt
file that have changes for both change sets. Commit with:Answer questions, for example: