我有两个补丁,我想在mercurial合并。可悲的是,我删除了导出这些补丁的分支。你们可以建议一种合并这两个补丁的方法吗?
我在ubuntu 12.04盒子上使用Mercurial 2.0.2。
答案 0 :(得分:4)
如果启用了MQ,并假设您以空的补丁队列开头:
> hg qimport patch1 # Import & apply the first patch into a patch queue
> hg qimport patch2 # Import & apply the second patch into a patch queue
> hg qpop; # Pop the second patch (unapply)
> hg qfold patch2 # Fold the second patch into the first (result is called 'patch1')
> hg qexport > new_merged_patch
然后你可以:
> hg qfinish -a # Convert the currently applied patches (e.g. patch1) to changesets)
或:
> hg qpop # Pop the merged patch
> hg qdel patch1 # Delete it from the queue
老实说,使用MQ是一种矫枉过正,但这是一个有用的扩展知识。
答案 1 :(得分:3)
如果您将补丁作为补丁文件,您可以将它们相互应用并根据结果生成补丁:
$ patch -p0 < patch1
$ patch -p0 < patch2
$ hg diff > cumulative.patch
补丁级别-p0
可能会有所不同,具体取决于补丁的结构。