diff -r acebcefa86d4 -r 66d7a1250c9b mercurial/patch.py --- a/mercurial/patch.py Thu Dec 02 01:28:38 2010 -0200 +++ b/mercurial/patch.py Fri Dec 03 11:40:30 2010 +0900 @@ -485,6 +485,15 @@ for x, s in enumerate(self.lines): self.hash.setdefault(s, []).append(x) + def makerejlines(self, fname): + base = os.path.basename(fname) + yield "--- %s\n+++ %s\n" % (base, base) + for x in self.rej: + for l in x.hunk: + yield l + if l[-1] != '\n': + yield "\n\ No newline at end of file\n" + def write_rej(self): # our rejects are a little different from patch(1). This always # creates rejects in the same form as the original patch. A file @@ -499,16 +508,9 @@ _("%d out of %d hunks FAILED -- saving rejects to file %s\n") % (len(self.rej), self.hunks, fname)) - def rejlines(): - base = os.path.basename(self.fname) - yield "--- %s\n+++ %s\n" % (base, base) - for x in self.rej: - for l in x.hunk: - yield l - if l[-1] != '\n': - yield "\n\ No newline at end of file\n" - - self.writelines(fname, rejlines()) + fp = self.opener(fname, 'w') + fp.writelines(self.makerejlines(self.fname)) + fp.close() def apply(self, h): if not h.complete():