patch: add diffstatsum helper
authorMatt Mackall <mpm@selenic.com>
Sat, 21 May 2011 15:06:36 -0500
changeset 14401 7bb7be1c1385
parent 14400 cd1ca2556cac
child 14402 f03f08240c32
patch: add diffstatsum helper
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(.*)$')