Mercurial/SVN:来自一组差异的多次提交?
假设我正在开发一个包含文件 A、B 和 C 的项目。在添加功能、修改 A 和 B 的过程中,我意识到有些东西需要清理。鉴于这种情况,最好中断功能工作来进行清理。这涉及到对 A、B 和 C 进行更改。
完成该功能后,我想签入我的代码。可以这么说,有两组不同的更改:用于添加功能的更改和用于清理的更改。它们在任何方面都不冲突。是否可以单独提交这些更改,以获得干净的回购历史记录?
或者,如果我决定在完成后立即签入清理工作,但不想签入 A 和 B 中已完成一半的功能,该怎么办?
我不确定是否可以在 Mercurial 或 SVN 中执行此操作,但我有兴趣了解其中任何一个。 (TortoiseHg 怎么样?)
Let's say that I'm working on a project, with files A, B, and C. I get halfway through adding a feature, modifying A and B, before I realize that something needs cleaning. Because of the circumstances, it's optimal to interrupt the feature work to do the cleaning. This involves making changes in A, B, and C.
After I'm done with the feature, I want to check in my code. There are two different sets of changes, so to speak: those for adding the feature, and those for the cleanup. They do not conflict in any way. Is it possible to commit these changes separately, for a clean repo history?
Alternatively, what if I decided to check in the cleanup as soon as I was done with it, but didn't want to check in the halfway-completed feature in A and B?
I'm not sure if it's possible to do this in Mercurial or SVN, but I am interested in learning about either. (What about TortoiseHg?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您可以使用 Mercurial 的
hg record
来完成此操作。它被认为是一个扩展,但它与常规包一起分发。基本上,您运行该命令,它会询问您有关每个文件的信息(您想从这里提交任何内容吗?)。如果您回答“是”,它会询问您是否要提交每个块(行组)。您还可以在特定文件上运行它。例如:在这种情况下,它不会费心询问您对其他文件的更改。
每个块的选项是:
编辑:TortoiseHg 有一个名为 更改选择,基本上相当于
record
的 GUI。Yes, you can do this with Mercurial's
hg record
. It's considered an extension, but it's distributed with the regular package. Basically, you run that command, and it asks you about each file (do you want to commit anything from here?). If you say yes, it asks you whether you want to commit each hunk (group of lines). You can also run it on particular files. E.g.:In that case, it won't bother asking you about changes to to other files.
The options for each hunk are:
EDIT: TortoiseHg has an integrated feature called Change Selection, which is basically a GUI equivalent of
record
.crecord 扩展提供了一个很好的 Curses 界面,可让您准确选择要提交的待处理更改。
The crecord extension provides a nice curses interface that lets you select exactly what pending changes you want to commit.