hgext/churn.py
changeset 46430 b84c3d43ff2e
parent 45942 89a2afe31e82
child 48875 6000f5b25c9b
--- a/hgext/churn.py	Mon Jan 25 12:31:40 2021 +0100
+++ b/hgext/churn.py	Sat Jan 30 18:30:11 2021 +0800
@@ -38,11 +38,16 @@
 def changedlines(ui, repo, ctx1, ctx2, fmatch):
     added, removed = 0, 0
     diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
+    inhunk = False
     for l in diff.split(b'\n'):
-        if l.startswith(b"+") and not l.startswith(b"+++ "):
+        if inhunk and l.startswith(b"+"):
             added += 1
-        elif l.startswith(b"-") and not l.startswith(b"--- "):
+        elif inhunk and l.startswith(b"-"):
             removed += 1
+        elif l.startswith(b"@"):
+            inhunk = True
+        elif l.startswith(b"d"):
+            inhunk = False
     return (added, removed)