##// END OF EJS Templates
churn: count lines that look like diff headers but are not...
Aay Jay Chan -
r47158:b84c3d43 default
parent child Browse files
Show More
@@ -38,11 +38,16 b" testedwith = b'ships-with-hg-core'"
38 def changedlines(ui, repo, ctx1, ctx2, fmatch):
38 def changedlines(ui, repo, ctx1, ctx2, fmatch):
39 added, removed = 0, 0
39 added, removed = 0, 0
40 diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
40 diff = b''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))
41 inhunk = False
41 for l in diff.split(b'\n'):
42 for l in diff.split(b'\n'):
42 if l.startswith(b"+") and not l.startswith(b"+++ "):
43 if inhunk and l.startswith(b"+"):
43 added += 1
44 added += 1
44 elif l.startswith(b"-") and not l.startswith(b"--- "):
45 elif inhunk and l.startswith(b"-"):
45 removed += 1
46 removed += 1
47 elif l.startswith(b"@"):
48 inhunk = True
49 elif l.startswith(b"d"):
50 inhunk = False
46 return (added, removed)
51 return (added, removed)
47
52
48
53
@@ -195,3 +195,22 b' Test --template argument, with backwards'
195 alltogether 11 *********************************************************
195 alltogether 11 *********************************************************
196
196
197 $ cd ..
197 $ cd ..
198
199 count lines that look like headings but are not
200
201 $ hg init not-headers
202 $ cd not-headers
203 $ cat > a <<EOF
204 > diff
205 > @@ -195,3 +195,21 @@
206 > -- a/tests/test-churn.t
207 > ++ b/tests/test-churn.t
208 > EOF
209 $ hg ci -Am adda -u user1
210 adding a
211 $ hg churn --diffstat
212 user1 +4/-0 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
213 $ hg rm a
214 $ hg ci -Am removea -u user1
215 $ hg churn --diffstat
216 user1 +4/-4 +++++++++++++++++++++++++++---------------------------
General Comments 0
You need to be logged in to leave comments. Login now