Date: February 28 2013
Abstract: Need to build a report based on your Subversion project? This free-to-attend online training will share techniques for extracting information from Subversion, for reporting purposes.
Topics include:
- Difference information
- Using Project and User information
- Using Hook scripts to log information
Mike, a 33 year veteran of the software industry, has spent the past 26 years delivering consulting and training services for Subversion and other software configuration management systems. He has taught over 700 classes covering various aspects of implementing and using Subversion and other SCMs.
Mike is currently WANdisco’s Director of Subversion Training.
3. Outline
• Log information
• Property information
▫ Log and Properties demonstration
• Difference information
• Using Project and User information
• Using Hook scripts to log information
▫ Hook script demonstration
3
4. This training is done with the latest
TortoiseSVN Version
http://www.wandisco.com/subversion/os/downloads
5. Extracting information out of the repository
Use the log
command
Use a hook script
Use the Subversion
API’s
Third party tools
7. Output from Log Command
Revision: 29
Author: Mike
Date: 3:53:04 PM, Sunday, May 08, 2011
Message:
QA Level:Change User Doc:
----
Modified : /BankDocSystem/trunk/auditbuild.asp
Revision: 29
Author: Mike
Modified : /BankDocSystem/trunk/borrowerdeleteconfirm.asp
Date: 3:53:04 PM, Sunday, May 08, 2011
Message:
Revision: 28 QA Level:Change User Doc:
Author: Mike ----
Modified : /BankDocSystem/trunk/auditbuild.asp
Date: 10:44:41 AM, Wednesday, May 04, 2011
Modified : /BankDocSystem/trunk/borrowerdeleteconfirm.asp
Message:
QA Level:unitChange User Doc:No Revision: 28
Author: Mike
---- Date: 10:44:41 AM, Wednesday, May 04, 2011
Modified : /BankDocSystem/trunk Message:
Modified : /BankDocSystem/trunk/Stored Procedures
QA Level:unitChange User Doc:No
----
Modified : /BankDocSystem/trunk/images Modified : /BankDocSystem/trunk
Modified : /BankDocSystem/trunk/include Modified : /BankDocSystem/trunk/Stored Procedures
Modified : /BankDocSystem/trunk/include/javascript : /BankDocSystem/trunk/images
Modified
Modified : /BankDocSystem/trunk/reports Modified : /BankDocSystem/trunk/include
Modified : /BankDocSystem/trunk/include/javascript
Modified : /BankDocSystem/trunk/reports
Revision: 27
Author: Mike Revision: 27
Author: Mike
Date: 10:42:08 AM, Wednesday, May 04, 2011 10:42:08 AM, Wednesday, May 04, 2011
Date:
Message: Message:
Cntrl
added copyright and owner
----
---- C
added copyright and owner
Modified : /BankDocSystem/trunk
Modified : /BankDocSystem/trunk Modified : /BankDocSystem/trunk/Stored Procedures
Modified : /BankDocSystem/trunk/Stored Procedures /BankDocSystem/trunk/images
Modified :
Copy and place
Modified : /BankDocSystem/trunk/images
in a text file
7
8. M /BankDocSystem/trunk sourceBankDocSystem>svn log -v
M /BankDocSystem/trunk/Stored Procedures
M /BankDocSystem/trunk/images
M /BankDocSystem/trunk/include
Output from Command Line Log Command
M /BankDocSystem/trunk/include/javascript
M /BankDocSystem/trunk/reports
QA Level:unit svn log -v
Change User Doc:No
------------------------------------------------------------------------
r27 | Mike | 2011-05-04 10:42:08 -0600 (Wed, 04 May 2011) | 1 line
Changed paths:
M /BankDocSystem/trunk
M /BankDocSystem/trunk/Stored Procedures
M /BankDocSystem/trunk/images
M /BankDocSystem/trunk/include
M /BankDocSystem/trunk/include/javascript
M /BankDocSystem/trunk/reports
added copyright and owner
------------------------------------------------------------------------
r26 | Mike | 2011-05-04 10:40:26 -0600 (Wed, 04 May 2011) | 1 line
Changed paths:
M /BankDocSystem/trunk
M /BankDocSystem/trunk/Stored Procedures
M /BankDocSystem/trunk/images
M /BankDocSystem/trunk/include
M /BankDocSystem/trunk/include/javascript
A /BankDocSystem/trunk/privacyPolicy.asp
M /BankDocSystem/trunk/reports
added a new file 8
9. sourceBankDocSystem>svn log -v
Output from Command Line Log Command
The log command can use the option:
--with-no-revprops
--with-all-revprops
--with-revprop AUTHOR
svn log file:///c:/bcd/trunk -v
svn log file:///c:/bcd/trunk/sort.asp -v
svn log file:///c:/bcd/trunk/ sort.asp tune.cpp -v
svn log –v 25:18 svn log –v 18:25
9
10. sourceBankDocSystem>svn log -v
Filtering the log command by date range
C:UsersMike>svn log file:///c:/devvc -r {2011-05-11}:{2011-03-13}
------------------------------------------------------------------------
You can specify r25 | Mike | 2011-03-13 07:00:04 -0600 (Sun, 13 Mar 2011) | 1 line
a date range Fixed Bug #284
------------------------------------------------------------------------
r24 | Mike | 2011-03-13 06:59:11 -0600 (Sun, 13 Mar 2011) | 1 line
Fixed Bug #2214
------------------------------------------------------------------------
r23 | Mike | 2011-03-13 06:58:26 -0600 (Sun, 13 Mar 2011) | 2 lines
Finished with
Enhancement 227F
svn log file:///c:/devvc -r {2011-05-11}:{2011-03-13}
------------------------------------------------------------------------
r22 | Mike | 2011-03-13 06:57:42 -0600 (Sun, 13 Mar 2011) | 2 lines
Working on db struct
Enhancement 227F
------------------------------------------------------------------------
r21 | Mike | 2011-03-13 06:57:01 -0600 (Sun, 13 Mar 2011) | 2 lines
Woring on db struct
Enhancement 227F
------------------------------------------------------------------------
r20 | Mike | 2011-03-13 06:54:07 -0600 (Sun, 13 Mar 2011) | 1 line
Creating branch to update db structure to take advantage of new indexing
------------------------------------------------------------------------
r19 | Mike | 2011-03-13 06:52:09 -0600 (Sun, 13 Mar 2011) | 1 line
Fixed Bug #321
------------------------------------------------------------------------
r18 | Frank | 2011-03-12 09:55:32 -0700 (Sat, 12 Mar 2011) | 1 line
Working on Feature #123
------------------------------------------------------------------------
10
11. Showing additional columns on
“Check for modifications”
You can add columns of properties used
in any of the objects
11
12. Showing additional columns on
“Check for modifications”
Select columns to
show
By default the columns are added to the end of the set of
columns – you can drag them anywhere
12
13. Unified-diff format
This format is used
by many different
version control
systems.
14. Unified-diff format
This format is used
by many different
version control
systems.
15. Repository Information – The log command
The LOG command reports
on log messages from a repository
C:sourcetestpayroll>svn log file:///C:/repository/payroll -v
You can filter on ------------------------------------------------------------------------
- Projects r4 | Mike | 2010-11-27 07:16:20 -0700 (Sat, 27 Nov 2010) | 1 line
Changed paths:
- Revision D /payroll/colors.txt
- Date A /payroll/common/emails.txt
M /payroll/common/mrtechie.htm
Fixed bug #449
------------------------------------------------------------------------
r3 | Mike | 2010-11-27 07:15:19 -0700 (Sat, 27 Nov 2010) | 2 lines
Changed paths:
M /payroll/days.txt
A /payroll/scluc_3_wd/test.js
Modified sort routine
German sort now works
------------------------------------------------------------------------
r2 | Mike | 2010-11-27 07:14:30 -0700 (Sat, 27 Nov 2010) | 1 line
Changed paths:
M /payroll/numbers.txt
M /payroll/scluc_3_wd/scl_3_wd.html
Fixed bug #442
------------------------------------------------------------------------
16. Repository Information – Making log info more useful
The LOG command output can be made into XML
C:sourcetestpayroll>svn log file:///C:/repository/payroll -v --xml
<?xml version="1.0"?>
<log>
<logentry
revision="4">
There are many <author>Mike</author>
<date>2010-11-27T14:16:20.503414Z</date>
ways to import <paths>
<path
XML into kind="file"
databases action="D">/payroll/colors.txt</path>
<path
kind="file"
action="M">/payroll/common/mrtechie.htm</path>
<path
kind="file"
action="A">/payroll/common/emails.txt</path>
</paths>
<msg>Fixed bug #449</msg>
</logentry>
17. Using log info from SQL
There are only two tables you need to create
CREATE TABLE logentry(
revisionNumber int,
revisionAuthor nvarchar(50) ,
revisionDate datetime,
dateAdded datetime NULL,
revisionLogMsg nvarchar(max) )
ParseSubversion
CREATE TABLE path(
revisionNumber int ,
pathKind nchar10) ,
pathAction nchar(10),
pathString nvarchar(max),
pathCopyfromPath nvarchar(max),
pathCopyfromRev nchar(10) ,
dateAdded datetime)
18. Using log info from SQL
Then you can do any type reporting or analysis you desire
19. Using log info from SQL
To see how the number of commits change about a project
SELECT
MONTH(revisionDate) as 'Month',
YEAR(revisionDate) as 'Year',
COUNT(*) as 'No. of Revisions'
FROM logentry
GROUP BY MONTH(revisionDate),
YEAR(revisionDate)
20. Using log info from SQL
To see who is making the most commits
SELECT
count(*) as '# of Commits',
revisionAuthor as 'Author'
FROM logentry
group by revisionAuthor
CraigA
Number of Commits Frank
400
EliM
300
MathewT
200
SvnIntegra
100 tion
Bob
0
Developers Susan
21. Another Output Example – Code Reviews
The problem
• We have a standard of doing code reviews on
development work
• We need to mark which code should be reviewed
and who should do reviews
• We need a report showing
• Which code needs to be reviewed
• Who should do the reviews
• Which code has been marked as “to be
reviewed” but no one was assigned to review
the code
25. Now we need a report to tell people what to do
What has to be reported
Which files do not have the properties
CodeReviewed and CodeReviewer
Which files in the last week (month) changed from
CodeReviewed = NO to CodeReviewed = ReadyForReview
Which files have been set to
CodeReviewed = YES for over 6 weeks
26. Hook script workshop
Every hook script should start with a
policy and a procedure
Policy : Any changes to Log
messages must be logged.
Procedure : Contact the Subversion
administrator and tell them what was
changed.
26
27. Hook script workshop
WHY DO WE CARE
ABOUT THE POLICY
“Any changes to Log or Author
properties must be logged.”
If we verify changes, and the log
Some log information triggers
Sometimes people type things
messages change how do we
events or is moved to
incorrectly
know if the Audit is valid.
Issue/Bug/Planning systems
27
28. Hook script workshop
We need to have some way of
making sure the changes to Log
Messages are OK
Options
Have Have
Periodically
Only allow Only allowpermissions
Only allowpermissions
make lists of
administrators
administrators change to change
administrators
to
all logs and
to change logslogs be
to change logs to change logslogs be
compare
turned on/off
turned on/off
28
29. Hook script workshop
Or turn the control over to
a hook script
Steps
• Which hook script
• What language
• Write some code
• Test it
• Implement it
29
30. Hook script workshop
pre-revprop-change
Which hook script ?
This runs before any changes
Must exist and return 0 to allow changes
start-commit
pre-unlock
post-revprop-change
pre-revprop-change
pre-revprop-change
This runs after any changes
pre-lock used to create a file
Can be
This runs before any changes
or
pre-commit and return 0 to allow changes
Must exist
Email information
post-unlock
Will not run unless the pre-revprop-change
post-revprop-change
hook exists
post-lock after any changes
This runs
post-commit
30
31. Hook Scripts - post-revprop-change
post-revprop-change
This is run immediately after the revision property
change
Will not run unless the pre-revprop-change hook
is run successfully
Input parameters :
• Repository path
• Name of revision whose property is
about to be modified Common Uses
• Username attempting the property Send an email
change notification that the
• Name of the property property has been
• Name of change A (added), changed
D (deleted), or M (modified)
31
32. Hook script workshop
Which language ?
Batch file
Python
Perl
Windows script (Javascript)
Any EXE
As long as it can be passed
parameters and return an error
code
Any code, if initiated by a BAT file
32
33. Hook script workshop
Plan your program
Subversion Post-revprop-change.bat Post-revprop-change.js Log File
Get log
message
Repository
33
34. Hook script workshop
Where does the
log file go ?
Post-revprop-change.js Log File
function writefile(textToWrite,repPath)
{
var fso=new ActiveXObject("Scripting.FileSystemObject");
var txtFile=fso.OpenTextFile(repPath + "post-reprop-change.log",8,true,0);
var str=textToWrite;txtFile.WriteLine(str);
txtFile.Close();
}
34
35. Hook script workshop
What should the
log file output be? ------Sun Feb 27 15:16:27 MST 2011------
Repository path=C:demoAdminLock
Revision=7
It also could be
User=MIke
Modified Property=svn:log
Log File Action=M
-tab delimited
-comma separated
Old log message=fixed bug 12321 see feature 1881
New log message=fixed bug 12321 see feature 1889
02272011-15:16:27,”C:demoAdminLock “,7,”MIke “,”svn:log”,”M“,”fixed bug 12321 see
feature”,”fixed bug 12321 see feature 1889” ------Sun Feb 27 15:17:49 MST 2011------
Repository path=C:demoAdminLock
02172011-07:12:33,”C:demoAdminLock “,4,”MIke “,”svn:log”,”M“,” made a copy of trunk into
Revision=6
tags/rel 1.0”,” made a copy of trunk into tags/rel 1.0/0D/0ARelease sent to QA - 2/23/2011“
User=MIke
Modified Property=svn:log
Action=M
Old log message=made a copy of trunk into tags/rel 1.0
New log message=made a copy of trunk into tags/rel 1.0
Release sent to QA - 2/23/2011
35
36. Edit The File
Now you need to do some
Check
out programming. Going through
whatever development steps are
Commit Edit
your standards.
Update
And use Subversion for version
control.
Test Edit
Edit Test
36
37. And we have a new policy and procedure
Policy : All changes to Log properties
must be reviewed weekly.
Procedure : The administrator will review
the log file for “Changed Log Messages”
every week and report anything suspicious
to the project leaders.
The log files are in …………
Contact the managers by email ………
37
38. Other hook script output examples
Policy : All branches that are classified as
READY-TO-MERGE must be tested by the QA
department.
Policy : All changes to projects
classified as inactive must be
reviewed by a project manager.
38
39. Conclusions
1. Decide which outputs will help you
manage your development efforts.
2. Design procedures or programs to
create reports.
3. Train staff on what will be reported.
39