Paste: diffstat
Author: | piranha |
Mode: | factor |
Date: | Fri, 16 Jan 2009 15:54:39 |
Plain Text |
IN: diffstat
USING: assocs combinators io kernel math namespaces sequences splitting ;
SYMBOL: stats
SYMBOL: fname
SYMBOL: curstats
: isstart swap start 0 = ;
: is-diffstart-line "diff" isstart ;
: is-plus-line [ "+++" isstart not ] [ "+" isstart ] bi and ;
: is-minus-line [ "---" isstart not ] [ "-" isstart ] bi and ;
: fname-git
" " split third 2 swap dup length swap subseq ;
: fname-uni " " split 5 tail " " join ;
: determine-fname [ dup "--git" start ]
[ fname-git ]
[ fname-uni ]
if ;
: inc-curstats
curstats get 2dup nth
1 + -rot set-nth ;
: finish-count curstats get fname get stats get set-at
{ 0 0 } clone curstats set
f fname set ;
: diffstat* {
{ [ dup is-diffstart-line ] [
fname get [ finish-count ] when
determine-fname fname set ] }
{ [ dup is-plus-line ] [ 0 inc-curstats drop ] }
{ [ dup is-minus-line ] [ 1 inc-curstats drop ] }
[ drop ]
} cond ;
: diffstat
H{ } clone stats set
{ 0 0 } clone curstats set
[ readln dup ] [ diffstat* ] [ drop ] while
finish-count stats get ;
Author: | piranha |
Mode: | factor |
Date: | Fri, 16 Jan 2009 19:38:24 |
Plain Text |
--- Data stack:
"diff --git a/hgext/churn.py b/hgext/churn.py"
R! diff --git a/(.*) b/(.*)!
(match) captured-groups>>
--- Data stack:
H{ ~array~ ~array~ }
.
H{
{
1
T{ slice
{ from 13 }
{ to 13 }
{ seq
"diff --git a/hgext/churn.py b/hgext/churn.py"
}
}
}
{
2
T{ slice
{ from 30 }
{ to 30 }
{ seq
"diff --git a/hgext/churn.py b/hgext/churn.py"
}
}
}
}
New Annotation