Mercurial > hg
changeset 14400:cd1ca2556cac
diffstatdata: no longer a generator
This produces a smallish amount of data and all consumers needed to
buffer it anyway.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 21 May 2011 15:01:28 -0500 |
parents | 71938479eff9 |
children | 7bb7be1c1385 |
files | mercurial/patch.py |
diffstat | 1 files changed, 10 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Wed May 18 21:31:40 2011 +0200 +++ b/mercurial/patch.py Sat May 21 15:01:28 2011 -0500 @@ -1684,12 +1684,17 @@ def diffstatdata(lines): diffre = re.compile('^diff .*-r [a-z0-9]+\s(.*)$') + results = [] filename, adds, removes = None, 0, 0 + + def addresult(): + if filename: + isbinary = adds == 0 and removes == 0 + results.append((filename, adds, removes, isbinary)) + for line in lines: if line.startswith('diff'): - if filename: - isbinary = adds == 0 and removes == 0 - yield (filename, adds, removes, isbinary) + addresult() # set numbers to 0 anyway when starting new file adds, removes = 0, 0 if line.startswith('diff --git'): @@ -1701,9 +1706,8 @@ adds += 1 elif line.startswith('-') and not line.startswith('---'): removes += 1 - if filename: - isbinary = adds == 0 and removes == 0 - yield (filename, adds, removes, isbinary) + addresult() + return results def diffstat(lines, width=80, git=False): output = []