##// END OF EJS Templates
mdiff: extract a checknonewline inner function in unidiff()
Denis Laxalde -
r31272:e41946f3 default
parent child Browse files
Show More
@@ -225,6 +225,12 b' def unidiff(a, ad, b, bd, fn1, fn2, opts'
225 fn1 = util.pconvert(fn1)
225 fn1 = util.pconvert(fn1)
226 fn2 = util.pconvert(fn2)
226 fn2 = util.pconvert(fn2)
227
227
228 def checknonewline(lines):
229 for text in lines:
230 if text[-1] != '\n':
231 text += "\n\ No newline at end of file\n"
232 yield text
233
228 if not opts.text and (util.binary(a) or util.binary(b)):
234 if not opts.text and (util.binary(a) or util.binary(b)):
229 if a and b and len(a) == len(b) and a == b:
235 if a and b and len(a) == len(b) and a == b:
230 return sentinel
236 return sentinel
@@ -258,11 +264,7 b' def unidiff(a, ad, b, bd, fn1, fn2, opts'
258 "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2)),
264 "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2)),
259 ]
265 ]
260
266
261 for ln in xrange(len(l)):
267 return headerlines, "".join(checknonewline(l))
262 if l[ln][-1] != '\n':
263 l[ln] += "\n\ No newline at end of file\n"
264
265 return headerlines, "".join(l)
266
268
267 def _unidiff(t1, t2, opts=defaultopts):
269 def _unidiff(t1, t2, opts=defaultopts):
268 """Yield hunks of a headerless unified diff from t1 and t2 texts.
270 """Yield hunks of a headerless unified diff from t1 and t2 texts.
General Comments 0
You need to be logged in to leave comments. Login now