##// END OF EJS Templates
patch: use `iter(callable, sentinel)` instead of while True...
Augie Fackler -
r29726:160c829d default
parent child Browse files
Show More
@@ -410,11 +410,7 b' class linereader(object):'
410 410 return self.fp.readline()
411 411
412 412 def __iter__(self):
413 while True:
414 l = self.readline()
415 if not l:
416 break
417 yield l
413 return iter(self.readline, '')
418 414
419 415 class abstractbackend(object):
420 416 def __init__(self, ui):
@@ -1688,10 +1684,7 b' def scanpatch(fp):'
1688 1684 def scanwhile(first, p):
1689 1685 """scan lr while predicate holds"""
1690 1686 lines = [first]
1691 while True:
1692 line = lr.readline()
1693 if not line:
1694 break
1687 for line in iter(lr.readline, ''):
1695 1688 if p(line):
1696 1689 lines.append(line)
1697 1690 else:
@@ -1699,10 +1692,7 b' def scanpatch(fp):'
1699 1692 break
1700 1693 return lines
1701 1694
1702 while True:
1703 line = lr.readline()
1704 if not line:
1705 break
1695 for line in iter(lr.readline, ''):
1706 1696 if line.startswith('diff --git a/') or line.startswith('diff -r '):
1707 1697 def notheader(line):
1708 1698 s = line.split(None, 1)
@@ -1772,10 +1762,7 b' def iterhunks(fp):'
1772 1762 context = None
1773 1763 lr = linereader(fp)
1774 1764
1775 while True:
1776 x = lr.readline()
1777 if not x:
1778 break
1765 for x in iter(lr.readline, ''):
1779 1766 if state == BFILE and (
1780 1767 (not context and x[0] == '@')
1781 1768 or (context is not False and x.startswith('***************'))
General Comments 0
You need to be logged in to leave comments. Login now