如何在 Mercurial 中将折叠的修订补丁应用到主干?
我正在寻找执行以下操作的最佳实践:
当我需要实现一项功能或修复错误时,我会从主存储库(主干)创建新的 Mercurial 存储库。 然后,在几天或几周内,我将在新创建的存储库中实现该任务,进行提交并定期与主干合并。在新存储库中的代码通过所有代码审查后,我应该提供一个存储库,其中所有更改都折叠为单个修订版。
我常用的方法(应启用 rdiff 扩展):
hg clone ~/repos/trunk ~/repos/new-collapsed cd ~/repos/new-collapsed hg diff ~/repos/new > new.diff patch -p1 < new.diff hg commit
这几乎可以很好地工作,除非~/repos/new 的更改中存在二进制文件。另一种方式可能是:
hg clone ~/repos/trunk ~/repos/new-collapsed cd ~/repos/new-collapsed hg pull ~/repos/new hg update hg rollback then resolve possible conflicts and manually commit the changes
这两种方式对我来说都有点丑陋和非本机,所以我正在寻找如何简化此操作。我玩过 rebase 扩展,但似乎它的 hg rebase --collapse< /code> 命令不适用于上述工作流程。
欢迎任何想法。
I am looking for best practices to do the following:
When I need to implement a feature or fix a bug, I am creating new Mercurial repository from the main one (a trunk).
Then, within some days, or weeks, I am implementing the task in newly created repository, making commits and periodically merging with trunk. After the code in new repository will pass all code reviews, I should provide a repository with all changes collapsed into single revision.
My common way to do this (rdiff extension should be enabled):
hg clone ~/repos/trunk ~/repos/new-collapsed cd ~/repos/new-collapsed hg diff ~/repos/new > new.diff patch -p1 < new.diff hg commit
This works almost well except when there are binary files present in the changes from ~/repos/new. Another way could be:
hg clone ~/repos/trunk ~/repos/new-collapsed cd ~/repos/new-collapsed hg pull ~/repos/new hg update hg rollback then resolve possible conflicts and manually commit the changes
Both ways look for me somewhat ugly and non-native, so I am looking how this operation could be simplified. I've played with rebase extension, but seems its hg rebase --collapse
command does not work with workflow described above.
Any ideas are welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来像是善变队列的一个很好的例子。
Sounds like a good case for mercurial queues.
我对 histedit 扩展执行类似的操作。
我的工作流程是这样的:
hg histedit
,并根据需要选择/丢弃/折叠修订hg push 折叠的存储库到中央存储库
我通过向
添加无效的
文件。default-push
路径来确保我的本地存储库永远不会被推送到中央存储库本地存储库根目录中的 >.hg/hgrcI do something similar with the histedit extension.
My workflow is something like:
hg histedit
and select/discard/fold the revisions as neededhg push
the collapsed repo to central repoI ensure that my local repo never gets pushed to the central repo by adding an invalid
default-push
path to the.hg/hgrc
file in the local repo root directory.已解决:只需添加
到您的 hgrc 文件,然后使用我的第一个解决方案和 rdiff 扩展名,将
patch
替换为hg import
:Solved: Just add
to your hgrc file, and then use my first solution with rdiff extension, replacing
patch
withhg import
: