changeset 14349:776ae95b8835

patch: merge makerejlines() into write_rej()
author Patrick Mezard <pmezard@gmail.com>
date Tue, 17 May 2011 23:46:37 +0200
parents c1c719103392
children 00da6624e167
files mercurial/patch.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/patch.py	Tue May 17 23:46:15 2011 +0200
+++ b/mercurial/patch.py	Tue May 17 23:46:37 2011 +0200
@@ -543,15 +543,6 @@
             cand.sort(key=lambda x: abs(x - linenum))
         return cand
 
-    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
@@ -559,8 +550,14 @@
         # without having to type the filename.
         if not self.rej:
             return
-        self.backend.writerej(self.fname, len(self.rej), self.hunks,
-                              self.makerejlines(self.fname))
+        base = os.path.basename(self.fname)
+        lines = ["--- %s\n+++ %s\n" % (base, base)]
+        for x in self.rej:
+            for l in x.hunk:
+                lines.append(l)
+                if l[-1] != '\n':
+                    lines.append("\n\ No newline at end of file\n")
+        self.backend.writerej(self.fname, len(self.rej), self.hunks, lines)
 
     def apply(self, h):
         if not h.complete():