2012-11-29 36 views
2

我有兩個我想在mercurial中合併的修補程序。不幸的是,我刪除了我導出這些補丁的分支。你們可以請建議一種合併這兩個補丁的方法嗎?合併Mercurial中的兩個修補程序

我在Ubuntu 12.04盒子上使用Mercurial 2.0.2。

+0

什麼阻止你爲每個補丁單獨提交? –

+1

沒有任何東西阻止我,但是,我希望將該補丁提交給開源項目,所以我認爲只發送一個補丁而不是很多補丁會很乾淨。 – kan

回答

3

如果你有補丁的補丁文件,你可以應用它們在彼此的頂部和基於結果的補丁:

$ patch -p0 < patch1 
$ patch -p0 < patch2 
$ hg diff > cumulative.patch 

的補丁級別,-p0,可能會根據不同你的補丁是結構化的。

3

如果啓用了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來做這件事是矯枉過正的,但它是知道的一個有用的擴展。

相關問題