可以用python模块difflib创建与GNU patch兼容的补丁? 我尝试使用统一的\u diff和context_diff,也尝试将lineterm指定为“\n”,但仍遇到以下错误:
[intense@Singularity Desktop]$ patch diff.patch test.txt
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
我用过文件.writelines(diff)将修补程序写入文件(代码段http://pastebin.com/3HAWfwVf)
文件测试.txt公司名称:
^{pr2}$文件test2.txt:
Hello, this is test
blah, dfsgjdfgj
lfkdjgkldfjgkldfjgkl
以及生成的补丁:
--- /home/intense/Desktop/test.txt
+++ /home/intense/Desktop/test2.txt
@@ -1,2 +1,7 @@
-Hello, this is test
-blah+Hello,+this+is+test+blah,+dfsgjdfgj+lfkdjgkldfjgkldfjgkl
谢谢你的帮助。在
diff -rNau dir-v1/ dir-v2/ > 1-2.patch
代替difflib。在我将使用mercurialsbdiff模块,它比difflib快得多。在
相关问题 更多 >
编程相关推荐