当 hg mq 补丁队列中的单个补丁中有太多更改时该怎么办?
hg mq 插件的目的是能够对您的存储库进行完美的提交,而不会混淆您在心不在焉的 ADHD 引起的漫无目的代码中所做的更改;
例如......
当我注意到错误 y 并开始处理错误 x 时,我就开始处理它。此时,您应该在补丁队列中创建一个新补丁,以免在 hg qfinish
提交到存储库时混淆更改。
现在假设您在 hg qrefresh
过程中忘记了制作新补丁。后来意识到你的错误,你希望将一个补丁的更改分成两个补丁。
我意识到这与编辑队列中的补丁文件(和新的补丁文件)有关,以将更改分成单独的补丁并稍后提交。但是,我还不擅长编辑 diff 补丁文件。
我可以在哪里了解这方面的信息?我们该如何解决这个问题呢?
The purpose of the hg mq plugin is to be able to make perfect commits to your repository, not confusing the changes that you made in your absent-minded ADHD induced rambling through your code;
For instance....
I'm working on bug x when I notice bug y and start working on it instead. At this point you are supposed to create a new patch in the patch queue so as not to confuse the changes when it is hg qfinish
committed to your repository.
Now suppose for a minute that you forget make the new patch and in the process hg qrefresh
. Then later realizing your mistake you wish to separate the changes from that one patch into two patches.
I realize that it has to do with editing your patch file (and a new patch file) in the queue to separate the changes into separate patches and later commits. However, I'm not yet skilled at editing the diff patch files.
Where can I learn about this? And how might one go about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
另一个选择(假设它在您的平台上运行)是 TortoiseHG 2.0 版本。 “不恰当”命名的 Shelve 实用程序允许在补丁之间移动块和文件,或者移动到工作目录中。它适用于 Windows、Linux,也可能适用于 OSX。
http://tortoisehg.bitbucket.io/
Another option (assuming it runs on your platform) is version 2.0 of TortoiseHG. The 'inappropriately' named Shelve utility allows for moving of chunks and files between patches, or into the working directory. It's available for Windows, Linux and possibly OSX.
http://tortoisehg.bitbucket.io/
如相关SO问题,查看“将一个补丁分割为多个补丁”部分MQ教程。
As noted in this related SO question, check out the "Split a patch into multiple patches" section of the MQ tutorial.
您可以激活记录扩展,将以下行添加到 .hgrc:
您可以清除您当前的补丁
(请注意,“
nothing
”只是一个随机字符串:qrefresh
的参数是当前补丁中必须包含的文件列表,因此任何不是修改文件名的东西都可以 - 我通常使用“0”)现在使用
hg qrecord
您可以交互式地选择哪些更改必须包含在新补丁中。然后可以使用qnew
或另一个qrecord
将剩余的更改添加到另一个补丁中。您最终可以使用qpop
、qfold
或编辑.hg/patches/series
来合并和重新排序补丁。You can activate the record extension, adding to .hgrc the following lines:
You can clear your current patch with
(note that the "
nothing
" is just a random string: the arguments toqrefresh
is the list of files which must be included in the current patch, so anything that is not the name of a modified file will do - I usually use "0")Now with
hg qrecord <patchName>
you can choose interactively which changes must go in the new patch. The remaining changes can then be added to another patch withqnew
or anotherqrecord
. You can finally useqpop
,qfold
or edit.hg/patches/series
to merge and reorder the patches.我有一个 shell 别名
viq="vim $(hg root)/.hg/patches/"
,我只在这些情况下使用它!我只需运行 viq 来提取补丁,然后手动编辑差异并根据需要将块移动到其他补丁中。
与交互式方法(例如, git add -i )相比,我更喜欢这种方法,因为我觉得在交互式提示下工作不像在编辑器中工作那样安全(我知道我的编辑器会进行备份,有微不足道的撤消等……)。
I have a shell alias,
viq="vim $(hg root)/.hg/patches/"
, that I use for just these situations!I'll just run
viq
to pull up the patches, then hand-edit the diff and move the hunks into other patches as appropriate.I prefer this over interactive methods (eg,
git add -i
) because I don't feel as safe working from the interactive prompt as I do working from my editor (I know that my editor makes backups, has trivial undo, etc…).