Mercurial > public > mercurial-scm > hg-stable
diff mercurial/patch.py @ 13104:5dac0d04b838
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 08 Dec 2010 13:12:12 -0600 |
parents | cfedc529e4a1 66d7a1250c9b |
children | 039a964dbbb3 |
line wrap: on
line diff
--- a/mercurial/patch.py Wed Dec 08 11:18:26 2010 -0600 +++ b/mercurial/patch.py Wed Dec 08 13:12:12 2010 -0600 @@ -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():