changeset 14401:7bb7be1c1385

patch: add diffstatsum helper
author Matt Mackall <mpm@selenic.com>
date Sat, 21 May 2011 15:06:36 -0500
parents cd1ca2556cac
children f03f08240c32
files mercurial/patch.py
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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(.*)$')