mercurial/crew
changeset 7886:7bcce39e8f07
Returns lines changed for paths specified as arguments correctly.
This fixes issue 1569. hg churn <path> now returns only the number
of lines changed in the path, if the path is specified by filtering
files through a match filter at the changeset level. test-churn
has been updated to take care of this issue.
This fixes issue 1569. hg churn <path> now returns only the number
of lines changed in the path, if the path is specified by filtering
files through a match filter at the changeset level. test-churn
has been updated to take care of this issue.
| author | madhu@madhu |
|---|---|
| date | Wed Mar 25 01:49:03 2009 +0530 (16 months ago) |
| parents | bc027d72c289 |
| children | 4b76746a988b |
| files | hgext/churn.py tests/test-churn tests/test-churn.out |
line diff
1.1 --- a/hgext/churn.py 1.2 +++ b/hgext/churn.py 1.3 @@ -21,9 +21,10 @@ 1.4 t.use_template(tmpl) 1.5 return t 1.6 1.7 -def changedlines(ui, repo, ctx1, ctx2): 1.8 +def changedlines(ui, repo, ctx1, ctx2, fns): 1.9 lines = 0 1.10 - diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node())) 1.11 + fmatch = cmdutil.match(repo, pats=fns) 1.12 + diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch)) 1.13 for l in diff.split('\n'): 1.14 if (l.startswith("+") and not l.startswith("+++ ") or 1.15 l.startswith("-") and not l.startswith("--- ")): 1.16 @@ -71,7 +72,7 @@ 1.17 continue 1.18 1.19 ctx1 = parents[0] 1.20 - lines = changedlines(ui, repo, ctx1, ctx) 1.21 + lines = changedlines(ui, repo, ctx1, ctx, fns) 1.22 rate[key] = rate.get(key, 0) + lines 1.23 1.24 if opts.get('progress'):
2.1 --- a/tests/test-churn 2.2 +++ b/tests/test-churn 2.3 @@ -20,7 +20,15 @@ 2.4 hg ci -m changeca -u user3 -d 12:00 a 2.5 hg ci -m changecb -u user3 -d 12:15 b 2.6 hg ci -Am addc -u user3 -d 12:30 2.7 +mkdir -p d/e 2.8 +echo abc > d/e/f1.txt 2.9 +hg ci -Am "add d/e/f1.txt" -u user1 -d 12:45 d/e/f1.txt 2.10 +mkdir -p d/g 2.11 +echo def > d/g/f2.txt 2.12 +hg ci -Am "add d/g/f2.txt" -u user1 -d 13:00 d/g/f2.txt 2.13 2.14 +echo % churn separate directories 2.15 +hg churn d/e 2.16 echo % churn all 2.17 hg churn 2.18 echo % churn up to rev 2
3.1 --- a/tests/test-churn.out 3.2 +++ b/tests/test-churn.out 3.3 @@ -2,22 +2,25 @@ 3.4 adding a 3.5 adding b 3.6 adding c 3.7 +% churn separate directories 3.8 +user1 1 *************************************************************** 3.9 % churn all 3.10 user3 3 *************************************************************** 3.11 +user1 3 *************************************************************** 3.12 user2 2 ****************************************** 3.13 -user1 1 ********************* 3.14 % churn up to rev 2 3.15 user2 2 *************************************************************** 3.16 user1 1 ******************************* 3.17 % churn with aliases 3.18 alias3 3 ************************************************************** 3.19 +alias1 3 ************************************************************** 3.20 user2 2 ***************************************** 3.21 -alias1 1 ******************** 3.22 % churn with column specifier 3.23 user3 3 *********************** 3.24 +user1 3 *********************** 3.25 user2 2 *************** 3.26 -user1 1 ******* 3.27 % churn by hour 3.28 -06 1 ********************** 3.29 -09 2 ******************************************** 3.30 -12 3 ****************************************************************** 3.31 +06 1 **************** 3.32 +09 2 ********************************* 3.33 +12 4 ****************************************************************** 3.34 +13 1 ****************
