如何将TortoiseSVN生成的补丁应用于Windows中的git存储库?

时间:2013-06-07 12:26:56

标签: git svn patch quantlib

我正在开发一个颠覆的项目,但在我设法提交最新更改之前,它已迁移到git。我使用TortoiseSVN创建了一个补丁文件,但现在我不知道如何应用它。我尝试使用git apply,但它不起作用:

C:\Users\ga1009\Documents\quantlib>git apply ..\dev\Oasis\CatBond_QuantLib_wXL.p
atch
..\dev\Oasis\CatBond_QuantLib_wXL.patch:6: trailing whitespace.
/* This file is automatically generated; do not edit.     */
..\dev\Oasis\CatBond_QuantLib_wXL.patch:7: trailing whitespace.
/* Add the files to be included into Makefile.am instead. */
..\dev\Oasis\CatBond_QuantLib_wXL.patch:8: trailing whitespace.

..\dev\Oasis\CatBond_QuantLib_wXL.patch:9: trailing whitespace.
#include <ql/experimental/catbonds/catbond.hpp>
..\dev\Oasis\CatBond_QuantLib_wXL.patch:10: trailing whitespace.
#include <ql/experimental/catbonds/catrisk.hpp>
error: QuantLib_vc10.vcxproj: No such file or directory
error: QuantLib_vc10.vcxproj.filters: No such file or directory
error: test-suite/quantlibtestsuite.cpp: No such file or directory
error: test-suite/testsuite_vc10.vcxproj: No such file or directory
error: test-suite/testsuite_vc10.vcxproj.filters: No such file or directory
error: gensrc/config/categories.xml: No such file or directory
error: gensrc/metadata/types/types.xml: No such file or directory
error: QuantLibObjects_vc10.vcxproj: No such file or directory
error: QuantLibObjects_vc10.vcxproj.filters: No such file or directory
error: qlxl/QuantLibXLStatic_vc10.vcxproj: No such file or directory
error: qlxl/QuantLibXLStatic_vc10.vcxproj.filters: No such file or directory

这些错误有点奇怪,因为所有这些文件都应该以另一个目录作为前缀,例如:来自补丁文件:

--- QuantLib/QuantLib_vc10.vcxproj  (revision 18468)
+++ QuantLib/QuantLib_vc10.vcxproj  (working copy)

我也按照https://stackoverflow.com/a/5415912/5363的建议尝试使用TortoiseMerge,但这个工具抱怨目标文件夹不是存储库(显然不是svn存储库)

编辑:来自gnuwin32项目的patch.exe抱怨相同的文件。补丁文件在某种程度上是错误的吗?第一个有错误的文件的条目是:

Index: QuantLib/QuantLib_vc10.vcxproj
===================================================================
--- QuantLib/QuantLib_vc10.vcxproj  (revision 18468)
+++ QuantLib/QuantLib_vc10.vcxproj  (working copy)
@@ -250,6 +250,11 @@
   <ItemGroup>
     <ClInclude Include="ql\cashflows\cpicoupon.hpp" />
     <ClInclude Include="ql\cashflows\cpicouponpricer.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\all.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\catbond.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\catrisk.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\montecarlocatbondengine.hpp" />
+    <ClInclude Include="ql\experimental\catbonds\riskynotional.hpp" />
     <ClInclude Include="ql\experimental\finitedifferences\dynprogvppintrinsicvalueengine.hpp" />
     <ClInclude Include="ql\experimental\finitedifferences\fdextoujumpvanillaengine.hpp" />
     <ClInclude Include="ql\experimental\finitedifferences\fdklugeextouspreadengine.hpp" />
@@ -1375,6 +1380,10 @@
   <ItemGroup>
     <ClCompile Include="ql\cashflows\cpicoupon.cpp" />
     <ClCompile Include="ql\cashflows\cpicouponpricer.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\catbond.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\catrisk.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\montecarlocatbondengine.cpp" />
+    <ClCompile Include="ql\experimental\catbonds\riskynotional.cpp" />
     <ClCompile Include="ql\experimental\finitedifferences\dynprogvppintrinsicvalueengine.cpp" />
     <ClCompile Include="ql\experimental\finitedifferences\fdextoujumpvanillaengine.cpp" />
     <ClCompile Include="ql\experimental\finitedifferences\fdklugeextouspreadengine.cpp" />

1 个答案:

答案 0 :(得分:1)

您可以尝试使用git-svn将svn存储库重新转换为git。一旦它在git中,你就可以在你现有的存储库中添加一个遥控器,然后从“忘记提交它”分支到正常分支中挑选有问题的提交。然后就推。

或者,去真正的低技术,只需使用差异/合并工具将文件更改从一个文件夹复制到另一个文件夹。