mercurial/patch.py
changeset 7664 3cc74ee75b0d
parent 7615 ab39d1813e51
child 7670 e5f445c94226
--- a/mercurial/patch.py	Sat Jan 17 15:25:20 2009 +0100
+++ b/mercurial/patch.py	Tue Jan 13 20:28:06 2009 +0200
@@ -1343,14 +1343,13 @@
         single(rev, seqno+1, fp)
 
 def diffstatdata(lines):
-    filename = None
+    filename, adds, removes = None, 0, 0
     for line in lines:
         if line.startswith('diff'):
             if filename:
                 yield (filename, adds, removes)
             # set numbers to 0 anyway when starting new file
-            adds = 0
-            removes = 0
+            adds, removes = 0, 0
             if line.startswith('diff --git'):
                 filename = gitre.search(line).group(1)
             else:
@@ -1360,7 +1359,8 @@
             adds += 1
         elif line.startswith('-') and not line.startswith('---'):
             removes += 1
-    yield (filename, adds, removes)
+    if filename: 
+        yield (filename, adds, removes)
 
 def diffstat(lines):
     output = []