Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/diffhelpers.c @ 5483:ec2cc1dadbf7
Handle patches with misformatted empty lines
Insert a space on empty lines which are missing a control character.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
---
I frequently receive emailed patches with empty lines represented as "\n\n",
where Mercurial expects them to be "\n \n". patch(1) applies these patches
without complaint, but qpush fails all hunks.
author | Hollis Blanchard <hollisb@us.ibm.com> |
---|---|
date | Thu, 01 Nov 2007 17:15:50 -0500 |
parents | 4574925db5c0 |
children | 900ccbd79ef7 |
comparison
equal
deleted
inserted
replaced
5482:e5eedd74e70f | 5483:ec2cc1dadbf7 |
---|---|
81 c = *s; | 81 c = *s; |
82 if (strcmp(s, "\\ No newline at end of file\n") == 0) { | 82 if (strcmp(s, "\\ No newline at end of file\n") == 0) { |
83 _fix_newline(hunk, a, b); | 83 _fix_newline(hunk, a, b); |
84 continue; | 84 continue; |
85 } | 85 } |
86 if (c == '\n') { | |
87 /* Some patches may be missing the control char | |
88 * on empty lines. Supply a leading space. */ | |
89 Py_DECREF(x); | |
90 x = PyString_FromString(" \n"); | |
91 } | |
86 PyList_Append(hunk, x); | 92 PyList_Append(hunk, x); |
87 if (c == '+') { | 93 if (c == '+') { |
88 l = PyString_FromString(s + 1); | 94 l = PyString_FromString(s + 1); |
89 PyList_Append(b, l); | 95 PyList_Append(b, l); |
90 Py_DECREF(l); | 96 Py_DECREF(l); |