[PATCH] apply patches with misformatted empty lines
Hollis Blanchard
hollisb at us.ibm.com
Tue Oct 30 21:23:24 UTC 2007
This has been bugging me for a while. When I save a patch from email,
then try to qpush it, I get rejects. patch(1) with the same patch file
applies cleanly. (No, it is not a line ending problem: all line endings
are LF).
The problem is that these patches are being sent with empty lines
represented as "\n\n", where hg expects them to be "\n \n". This patch
(apply with --ignore-whitespace) seems to solve the problem for me:
diff --git a/mercurial/diffhelpers.c b/mercurial/diffhelpers.c
--- a/mercurial/diffhelpers.c
+++ b/mercurial/diffhelpers.c
@@ -83,6 +83,12 @@ addlines(PyObject *self, PyObject *args)
_fix_newline(hunk, a, b);
continue;
}
+ if (c == '\n') {
+ /* Some patches may be missing the control char
+ * on empty lines. Supply a leading space. */
+ Py_DECREF(x);
+ x = PyString_FromString(" \n");
+ }
PyList_Append(hunk, x);
if (c == '+') {
l = PyString_FromString(s + 1);
Signed-off-by: Hollis Blanchard <hollisb at us.ibm.com>
--
Hollis Blanchard
IBM Linux Technology Center
More information about the Mercurial-devel
mailing list