一、使用前准备

需要安装svn命令行工具Subversion(现在安装包Setup-Subversion-1.8.9-1.msi直接安装即可)或者svn客户端(TortoiseSVN)和下载StatSVN包,现在地址sourceforge.net/projects/statsvn/

二、使用

解压压缩包,到一个目录,如c:\statsvn;

checkout 工作目录

从SVN服务器上checkout最新版本的项目文件,使用CMD首先导向到路径,c:\statsvn,然后运行命令:svn co https://172.23.1.80/svn/bookAirWorkspace/project/bookAir,这样项目的最新版本就load到c:\statsvn的目录下面;

生成log文件

导出SVN日志文件svn.log,使用命令:svn log  -v --xml C:\statsvn\bookAir > C:\statsvn\bookAir\svn.log;

使用StatSVN统计SVN中的代码量

运行StatSVN统计数据,命令:java -jar statsvn.jar C:\statsvn\bookAir\svn.log C:\statsvn\bookAir,当前CMD的工作路径还是c:\statsvn;

复杂统计指令:

java -jar statsvn.jar C:\statsvn\bookAir\svn.log C:\statsvn\bookAir -include **/*.java:**/*.jsp:**/*.js:**/*.css:**/*.xml

-exclude **/js/jquery-1.6.2.min.js

查看统计结果

等待一段时间,C:\statsvn目录下就会生成大量的统计文件,打开index.html即可进行查看。

三、高级使用

新建bat文件,statSVN.bat,内容为

svn log -v --xml -r {2016-12-19}:{2016-10-09} > svn.log
java -jar statsvn.jar svn.log ./ -charset gbk -output-dir ./report

svn log -v --xml -r {2010-12-01}:{2011-01-01} > svn.log java -jar statsvn.jar svn.log ./ -output-dir ./report

使用说明:

(1)将statsvn.jar和statSVN.bat这两个文件拷贝到要统计的chechout的目录下,例如D:/source_rep目录是存放svn检出的代码的路径。

d:/source_rep

|

----- .svn

|

----- statSVN.bat

|

----- statsvn.jar

(2)运行  statSVN.bat, 在d:/source_rep目录下生成是 svn.log文件和report目录

d:/source_rep

|

----- .svn

|

----- statSVN.bat

|

----- statsvn.jar

|

----- svn.log

|

----- report

|

---- index.html

(3){2010-12-01}:{2011-01-01} 显示了要统计代码的时间段。

注意在报告中显示的时间段是:

Report Period:

2010-12-02 to2010-12-31

参数中使用的均是开区间。(注:试了下按照日期倒置利用上面的脚本显示代码量时正确的,如svn log -v --xml -r {2016-05-20}:{2016-04-10} > svn.log )  而用前置则统计的不准确,不知道为什么

Author Lines of Code
honghailiang 8292 (49.6%)

(4) 使用IE浏览器,打开report/index.html,就可以查看统计代码开发情况了。



四、StatSVN优缺点分析

优点

StatSVN会把当前SVN库的状态用图片和图表的方式展现出来,可以按不同分类分别展开,功能强大。

缺点

StatSVN统计的是所有代码行,包括注释和空行,但一般度量要求是有效代码行,在分析时需要注意这一点。

StatSVN不考虑修改的代码行数,只考虑与上一版本相比新增(+)与删除(-)的代码行数。

五、遇到的问题

例如:用svn co http://xxxxxxxxxxx:xxxxx/svn/xxxx 下载代码后,会生成一个目录xxx其中包含了工程代码,如果直接在xxx下执行statSVN.bat(statsvn.jar中用到了svn diff命令)文件或者执行svn diff命令,会报如下错误

这个时候也能才生报告,但是修改代码的行数统计不到(比如我只是对某个文件代码做了修改,就是update操作,就统计不到),而只能统计出新增代码文件的代码行数。

而在下一级目录,比如src目录下执行statSVN.bat文件或者svn diff命令,就不会报错,报告中会包含修改代码的行数(同样不知道为什么)。



六、satasvn.jar选项   http://wiki.statsvn.org/User%20Manual.ashx    http://www.statsvn.org/

A list of all options understood by StatSVN follows.

General Options

-output-dir <directory>

Specify an output directory. The reports will be generated in this directory. The directory will be created if it doesn't exist.

-include <include-pattern-list>
-exclude <exclude-pattern-list>

Specify filters to exclude files from the analysis. A file will be ignored if it doesn't match any of the patterns ininclude-pattern-list, or if it matches any pattern inexclude-pattern-list.

The patterns are lists of Apache Ant-style wildcard patterns, seperated by colons or semicolons. The wildcards are:

  • '?' matches a single character
  • '*' matches zero or more characters
  • '**' matches zero or more directories

For example, src/**/*.java matches all java files in thesrc directory or its subdirectories. Note that*.java only matches java files in the root directory, because '*' does not match subdirectories.

One more example:

-include "**/*.c:**/*.h" -exclude "legacy/**"

This matches all .c and .h files anywhere in the directory tree except those in thelegacy directory and its subdirectories.

For more information on Ant's wildcard syntax, see thePatternset section of the Ant manual.

If not specified, all files will be included and no files will be excluded.

Note: Unix users must put the patterns in quotes, or the shell will interfere with the wildcards.

-cache-dir <directory>

Specify a cache directory for information retrieved from the Subversion server (e.g. line counts). The data will be saved in this directory. The directory will be created if it doesn't exist. By default, the current user directory is used.

-username <subversion_username>

Specify a username to use when connecting to the Subversion server.

-password <subversion_username>

Specify a password to use when connecting to the Subversion server.

-tags <tags-regularexpression>

Includes information about Subverison tags into the reports. Only tags matching the regular expression are included. To includeall tags, add-tags '.*' to the command line.

Note: Unix users must put the expression in quotes, or the shell will interfere with the wildcards.

Note: Tags are determined by looking at your repository's /tags directory. To be able to use this feature, you must generate the log file from the root of your repository, so that the log contains information from both the /tags and the /trunk. The checked out version does not have to contain the tags directory.

-tags-dir <directory>

Specifies the root directory from which the tags regular expression is evaluated. The default -tags-dir is/tags/

-no-developer <login-name>

Excludes a Subversion account name from all developer reports. This is useful to reduce noise from administrative and other non-developer accounts. Multiple accounts can be excluded by adding the option to the command line once for each account.

Report Options

-xdoc

Generate Maven XDoc instead of HTML. This allows Maven and Maven 2 to integrate the reports when it generates the projects Maven site. Reports could be placed, for example, intosrc/site/statsvn.

-xml

Generate XML instead of HTML.

-css <stylesheet>

Optional (default varies for html or xdoc). Specify aCascading Style Sheet for the report. This can be a HTTP URL or a local file. A URL will simply be linked in every page of the report. A local file will be copied into the report directory.

-notes <notes-file>

The contents of the specified file will be included at the top of the report's index page. The file should contain a valid block-level HTML fragment, for example:

<p>These are development statistics for the<a href="http://www.statsvn.org">StatSVN</a>project, created by StatSVN itself.
</p>
<p><strong>Note:</strong>This report was generated by an unreleaseddevelopment version of StatSVN. It mightcontain features not yet found in theofficial release.
</p>

-title <title>

Specifies a display title to be used in the reports. The name of the Subversion module will be used as default if no title is specified.

-config-file <path to properties file>

Allows one to replace the source control username with more information such as real name, website, email and avatar icon. Seethis file for an example.

-charset <charSet>

Specifies the charset to use in HTML or XDOC output. ISO-8859-1 will be used as default if no charset is specified.

-disable-twitter-button

if present, exclude the Twitter "Tweet This" buttons from the output.

Options for Integration with External Tools

-bugzilla

Specify the URL of a root of a Bugzilla installation. Will replace 'Bug ###' in commit logs with a link to the appropriate bug. (New in StatSVN)

-chora <chora-url>

Specify the URL of a Chora installation for the module. This must be the URL of the page for the module's root directory. StatSVN will create links to Chora for directories, files and revisions.

-viewvc <viewvc-url>

Specify the URL of a ViewVC installation for the module. This must be the URL of the page for the module's root directory. StatSVN will create links to ViewVC for directories, files and revisions.

-mantis <mantis-url>

Specify the root URL of a Mantis bug tracker installation. In commit messages, this will turn “Bug ####” into a link to the appropriate bug.

-trac <trac-url>

Specify the root URL of a Trac installation. In commit messages, this will turn “Bug ####” into a link to the appropriate bug.

Miscellaneous Options

-debug

Output lots of additional progress information.

-verbose

Output additional progress information.

-version

Output the version of StatSVN.

-dump

Will output the repository content on console and stop

-concurrency-threshold <millisec>

Switch to concurrent svn diff if the first call takes more than the threshold (in milliseconds) (default: 4000)

-threads <int>

How many threads for svn diff (default: 25)

-anonymize

Anonymizes committer names.

Examples

java -jar statsvn.jar -verbose -title jUCMNav -exclude **/src/urncore/**;**/src/grl/**;**/src/ucm/**;**/src/urn/**;**/src/seg/jUCMNav/model/ucm/** \-output-dir ./stats c:\eclipse\workspace\seg.jUCMNav\svn.log c:\eclipse\workspace\seg.jUCMNav



svn代码量统计工具StatSVN的使用相关推荐

  1. svn代码量统计工具

    StatSVN介绍 StatSVN是一个Java写的开源代码统计程序,从statCVS移植而来,能够从Subversion版本库中取得信息,然后生成描述项目开发的各种表格和图表.比如:代码行数的时间线 ...

  2. 几种代码量统计工具的安装及使用

    基于Windows的git代码统计工具GitStats 1.概述 GitStats是Git的一个统计工具,可以对项目进行比较细致的统计以html的形式展示,比较适合比较大的项目. GitStats在W ...

  3. 代码量统计工具,非常有用的小工具

    资源我已放在百度网盘,需要的朋友可以自行下载: 注:在操作中遇到问题或需要帮助可以联系博主 Pick up on demand 代码行数统计工具(CountLines)v2.1中文绿色版  链接:ht ...

  4. git代码量统计工具 -- 2017-12-20

    1. 按时间范围统计用户提交代码行数 自2017-01-01号以来的代码提交行数: git log --format='%aN' | sort -u | while read name; do ech ...

  5. linux 代码统计工具,Shell脚本实现的基于SVN的代码提交量统计工具

    最近没啥事,就用bash写了一个基于svn的代码统计小工具. 可以指定统计的目录,默认递归统计子目录. 目前还没有屏蔽指定目录的功能.哈 代码比较粗糙.不过先晒出来. #!/bin/bash - #& ...

  6. Svn的代码行数统计工具statsvn以及使用

    Svn代码行数统计 代码工具svnstat svnstat.jar的下载路径 使用方法 将下载好的jar文件放于本地svn版本库的根目录下,即.svn文件夹的同级目录下. 新增文本文件,内容为 svn ...

  7. eclipse代码量统计插件_Android Studio 代码行数统计插件Statistic的简单使用

    在项目开发过程中,有时候需要统计代码行数(比如组长想关心一下你的代码量,或者要申请软件著作权时),需要统计的文件类型主要是 .java..xml..kt等,已经有人开发好相关插件了,如果你是用Andr ...

  8. 代码行统计工具:根据命令行输入的指定目录及文件类型进行统计目录或单个文件的代码行数

    #统计指定目录(count_path).指定文件类型文件(file_types)的代码量 import os def count_all_file_code(count_path,file_types ...

  9. SVN代码统计工具statsvn

    http://pengtyao.iteye.com/blog/1001815 StatSVN简单使用说明 本文参考网上一些资料以及StatSVN官方手册编写 目录 StatSVN简单使用说明...1 ...

  10. SVN代码统计工具——statsvn

    ###1.介绍 StatSVN是一个Java写的开源代码统计程序,能够从Subversion版本库中取得信息,然后生成描述项目开发的各种表格和图表.比如:代码行数的时间线:针对每个开发者的代码行数:开 ...

最新文章

  1. 谈Linux的安全设置
  2. mysql日期格式化季度_mysql中常用日期比较与计算函数
  3. javascript,jquery 操作 dropdownlist ,select
  4. Windows环境下通过Git来管理自己的Android代码
  5. Google SSL zz
  6. win10隐藏linux,Win10如何隐藏Windows Defender任务栏图标
  7. Pycharm配置运行/调试时的工作目录
  8. Qt中添加静态库.lb,.a和动态库.dll,.so,头文件和.cpp文件
  9. 录音转文字python实现
  10. 【ARM汇编】ARM 指令集和Thumb 指令集
  11. 一张图,详解大数据技术架构
  12. Java方法重载中返回值的问题
  13. 对计算机病毒的防治也,对计算机病毒及防范对策研究.doc
  14. 深入浅出SpringBoot2.x
  15. 支付网关路由之设计方案实战
  16. JS,统计图表大全--十一、甘特图
  17. HbuilderX 启动微信小程序 无法打开项目
  18. 大数据分析——暑期黑马《延禧攻略》到底有多火!
  19. 电脑端知乎不显示图片
  20. 不允许sam账户和共享的匿名枚举_不允许SAM 帐户匿名枚举是什么意思?

热门文章

  1. qqkey获取原理_QQKEY获取多功能软件+【附源码】
  2. 如何制作双层PDF文档?其实只需简单一步!
  3. android的密码是多少,Android图形密码中 你最常用的是哪一个呢?
  4. centos修改用户密码图形化
  5. 肝一份java性能调优手册
  6. 在php页面出现乱码的原因,html网页乱码原因与解决方法
  7. Unity实现简单卡牌游戏框架
  8. 明解C语言(基础篇)—第七章
  9. 用Python写一个Excel汇总和比对小程序
  10. python调用默认播放器_在PotPlayer和MPV挂载SVP脚本进行补帧的部署方法