Show More
@@ -485,6 +485,15 b' class patchfile(object):' | |||
|
485 | 485 | for x, s in enumerate(self.lines): |
|
486 | 486 | self.hash.setdefault(s, []).append(x) |
|
487 | 487 | |
|
488 | def makerejlines(self, fname): | |
|
489 | base = os.path.basename(fname) | |
|
490 | yield "--- %s\n+++ %s\n" % (base, base) | |
|
491 | for x in self.rej: | |
|
492 | for l in x.hunk: | |
|
493 | yield l | |
|
494 | if l[-1] != '\n': | |
|
495 | yield "\n\ No newline at end of file\n" | |
|
496 | ||
|
488 | 497 | def write_rej(self): |
|
489 | 498 | # our rejects are a little different from patch(1). This always |
|
490 | 499 | # creates rejects in the same form as the original patch. A file |
@@ -499,16 +508,9 b' class patchfile(object):' | |||
|
499 | 508 | _("%d out of %d hunks FAILED -- saving rejects to file %s\n") % |
|
500 | 509 | (len(self.rej), self.hunks, fname)) |
|
501 | 510 | |
|
502 | def rejlines(): | |
|
503 | base = os.path.basename(self.fname) | |
|
504 | yield "--- %s\n+++ %s\n" % (base, base) | |
|
505 | for x in self.rej: | |
|
506 | for l in x.hunk: | |
|
507 | yield l | |
|
508 | if l[-1] != '\n': | |
|
509 | yield "\n\ No newline at end of file\n" | |
|
510 | ||
|
511 | self.writelines(fname, rejlines()) | |
|
511 | fp = self.opener(fname, 'w') | |
|
512 | fp.writelines(self.makerejlines(self.fname)) | |
|
513 | fp.close() | |
|
512 | 514 | |
|
513 | 515 | def apply(self, h): |
|
514 | 516 | if not h.complete(): |
@@ -141,3 +141,67 b' push again without LF and compare revisi' | |||
|
141 | 141 | $ hg qpop |
|
142 | 142 | popping eol.diff |
|
143 | 143 | patch queue now empty |
|
144 | $ cd .. | |
|
145 | ||
|
146 | ||
|
147 | Test .rej file EOL are left unchanged | |
|
148 | ||
|
149 | $ hg init testeol | |
|
150 | $ cd testeol | |
|
151 | $ python -c "file('a', 'wb').write('1\r\n2\r\n3\r\n4')" | |
|
152 | $ hg ci -Am adda | |
|
153 | adding a | |
|
154 | $ python -c "file('a', 'wb').write('1\r\n2\r\n33\r\n4')" | |
|
155 | $ hg qnew patch1 | |
|
156 | $ hg qpop | |
|
157 | popping patch1 | |
|
158 | patch queue now empty | |
|
159 | $ python -c "file('a', 'wb').write('1\r\n22\r\n33\r\n4')" | |
|
160 | $ hg ci -m changea | |
|
161 | ||
|
162 | $ hg --config 'patch.eol=LF' qpush | |
|
163 | applying patch1 | |
|
164 | patching file a | |
|
165 | Hunk #1 FAILED at 0 | |
|
166 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
|
167 | patch failed, unable to continue (try -v) | |
|
168 | patch failed, rejects left in working dir | |
|
169 | errors during apply, please fix and refresh patch1 | |
|
170 | [2] | |
|
171 | $ hg qpop | |
|
172 | popping patch1 | |
|
173 | patch queue now empty | |
|
174 | $ cat a.rej | |
|
175 | --- a | |
|
176 | +++ a | |
|
177 | @@ -1,4 +1,4 @@ | |
|
178 | 1\r (esc) | |
|
179 | 2\r (esc) | |
|
180 | -3\r (esc) | |
|
181 | +33\r (esc) | |
|
182 | 4 | |
|
183 | \ No newline at end of file | |
|
184 | ||
|
185 | $ hg --config 'patch.eol=auto' qpush | |
|
186 | applying patch1 | |
|
187 | patching file a | |
|
188 | Hunk #1 FAILED at 0 | |
|
189 | 1 out of 1 hunks FAILED -- saving rejects to file a.rej | |
|
190 | patch failed, unable to continue (try -v) | |
|
191 | patch failed, rejects left in working dir | |
|
192 | errors during apply, please fix and refresh patch1 | |
|
193 | [2] | |
|
194 | $ hg qpop | |
|
195 | popping patch1 | |
|
196 | patch queue now empty | |
|
197 | $ cat a.rej | |
|
198 | --- a | |
|
199 | +++ a | |
|
200 | @@ -1,4 +1,4 @@ | |
|
201 | 1\r (esc) | |
|
202 | 2\r (esc) | |
|
203 | -3\r (esc) | |
|
204 | +33\r (esc) | |
|
205 | 4 | |
|
206 | \ No newline at end of file | |
|
207 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now