# HG changeset patch<br># User <a href="mailto:madhusudancs@gmail.com">madhusudancs@gmail.com</a><br># Date 1237915643 -19800<br># Node ID 206d1dd65862d2fa6d6765ae3706e89b0430d76a<br># Parent  b2c18c7956221df0f961ac697a01effa1233978f<br>
Returns lines changed for paths specified as arguments correctly.<br><br>This fixes issue 1569. hg churn path now returns only the number<br>of lines changed in the path, if the path is specified. A test<br>case is also included.<br>
<br>diff --git a/hgext/churn.py b/hgext/churn.py<br>--- a/hgext/churn.py<br>+++ b/hgext/churn.py<br>@@ -21,9 +21,10 @@<br>     t.use_template(tmpl)<br>     return t<br> <br>-def changedlines(ui, repo, ctx1, ctx2):<br>+def changedlines(ui, repo, ctx1, ctx2, fns):<br>
     lines = 0<br>-    diff = &#39;&#39;.join(patch.diff(repo, ctx1.node(), ctx2.node()))<br>+    fmatch = cmdutil.match(repo, pats=fns)<br>+    diff = &#39;&#39;.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch))<br>
     for l in diff.split(&#39;\n&#39;):<br>         if (l.startswith(&quot;+&quot;) and not l.startswith(&quot;+++ &quot;) or<br>             l.startswith(&quot;-&quot;) and not l.startswith(&quot;--- &quot;)):<br>@@ -71,7 +72,7 @@<br>
                 continue<br> <br>             ctx1 = parents[0]<br>-            lines = changedlines(ui, repo, ctx1, ctx)<br>+            lines = changedlines(ui, repo, ctx1, ctx, fns)<br>             rate[key] = rate.get(key, 0) + lines<br>
 <br>         if opts.get(&#39;progress&#39;):<br>diff --git a/tests/test-issue1569 b/tests/test-issue1569<br>new file mode 100755<br>--- /dev/null<br>+++ b/tests/test-issue1569<br>@@ -0,0 +1,17 @@<br>+#!/bin/sh<br>+<br>+echo &quot;[extensions]&quot; &gt;&gt; $HGRCPATH<br>
+echo &quot;churn=&quot; &gt;&gt; $HGRCPATH<br>+<br>+mkdir t<br>+cd t<br>+hg init<br>+mkdir -p a/b<br>+mkdir -p a/c<br>+echo &quot;abc&quot; &gt; a/b/file.txt<br>+echo &quot;def&quot; &gt; a/c/file2.txt<br>+hg commit -A -m &quot;first commit&quot; -u testuser -d &#39;1 0&#39;<br>
+hg churn a/b<br>+<br>+echo expected output is 1<br>+echo done<br>diff --git a/tests/test-issue1569.out b/tests/test-issue1569.out<br>new file mode 100644<br>--- /dev/null<br>+++ b/tests/test-issue1569.out<br>@@ -0,0 +1,5 @@<br>
+adding a/b/file.txt<br>+adding a/c/file2.txt<br>+testuser      1 ************************************************************<br>+expected output is 1<br>+done<br><br clear="all"><br>-- <br>Thanks and regards,<br>  Madhusudan.C.S<br>
<br>Blogs at: <a href="http://www.madhusudancs.info">www.madhusudancs.info</a><br>Official Email ID: <a href="mailto:madhusudan@madhusudancs.info">madhusudan@madhusudancs.info</a><br>