[PATCH 2 of 4] patch: merge makerejlines() into write_rej()

Patrick Mezard pmezard at gmail.com
Sun May 8 11:43:33 CDT 2011


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1304871825 -7200
# Node ID da084b783ebc4d0d3b71ee70fc50e0fcd95b214c
# Parent  ef8f66cdac7f9fd8a497429b741607d8c9dbbdf5
patch: merge makerejlines() into write_rej()

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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():


More information about the Mercurial-devel mailing list