# HG changeset patch # User Matt Mackall # Date 2011-05-21 20:06:36 # Node ID 7bb7be1c13853487fa6fd980b622ec4779754dc8 # Parent cd1ca2556cac5d1eaf7f6a1f09c50b63d5ad0557 patch: add diffstatsum helper diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -1681,6 +1681,16 @@ def trydiff(repo, revs, ctx1, ctx2, modi 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(.*)$')