[PATCH 2 of 4] patch: merge makerejlines() into write_rej()
Patrick Mezard
pmezard at gmail.com
Tue May 17 15:11:18 CDT 2011
# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1305662129 -7200
# Node ID 2fb24321db2315ff9a543f2d7dda0e6a650a82c6
# Parent 6b7c8a7da95a45a3cbe8adc0db22db67c72aaedc
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