# HG changeset patch # User Matt Mackall # Date 1306008396 18000 # Node ID 7bb7be1c13853487fa6fd980b622ec4779754dc8 # Parent cd1ca2556cac5d1eaf7f6a1f09c50b63d5ad0557 patch: add diffstatsum helper diff -r cd1ca2556cac -r 7bb7be1c1385 mercurial/patch.py --- a/mercurial/patch.py Sat May 21 15:01:28 2011 -0500 +++ b/mercurial/patch.py Sat May 21 15:06:36 2011 -0500 @@ -1681,6 +1681,16 @@ if text: yield text +def diffstatsum(stats): + maxfile, addtotal, removetotal, binary = 0, 0, 0, False + for f, a, r, b in stats: + maxfile = max(maxfile, encoding.colwidth(f)) + addtotal += a + removetotal += r + binary = binary or b + + return maxfile, addtotal, removetotal, binary + def diffstatdata(lines): diffre = re.compile('^diff .*-r [a-z0-9]+\s(.*)$')