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