Is there a way to get a nice list of all commit messages sorted by file? Something like this (as you can see, I don't want the messages spec开发者_如何学Pythonific to a certain file, just show messages for the entire commit if the file was part of the commit, repeats ok):
-- index.php
2010-01-02 03:04:05
* added new paragraph
2010-01-01 03:04:05
* moved header out of index.php into header.php
* header.php initial check-in
2009-12-31 03:04:05
* index.php initial check-in
-- header.php
2010-01-03 03:04:05
* added new meta tags
2010-01-01 03:04:05
* moved header out of index.php into header.php
* header.php initial check-in
Additional information:
svn log filename
does something similar, but I want it to do this:
- get a list of files that have changed between yyyy-mm-dd (r2) and yyyy-mm-dd (r4)
(i.e.
svn log -q -v -r 2:4 > changedfiles.txt
- strip extraneous crap from changedfiles.txt
- svn log each file in that list, as in:
svn log < changedfiles.txt >> combinedlog.txt
(just pseudocode, i know svn log takes arguments not input, but can't be bothered to write it out)
svn log filename
will show all commit messages associated with filename
. The output will look something like the following:
------------------------------------------------------------------------
r1206 | kalebp | 2010-03-10 16:48:12 -0800 (Wed, 10 Mar 2010) | 1 line
Introduce a TranslatorFacade. Make the jar runnable by default.
------------------------------------------------------------------------
r1085 | kalebp | 2010-03-02 17:10:28 -0800 (Wed, 04 Nov 2009) | 1 line
Annotation checker now supports complete definitions and named parameters
------------------------------------------------------------------------
...
If you don't want information prior to a branch or copy there is a --stop-on-copy
option that you can add. See svn help log
for more information, such as how to specify date ranges, etc.
EDIT:
You can easily grab by a date range using svn log -r{20100101}:{20100331}
. I don't like the idea of calling log for changed files, so I'd recommend using the -v
flag to get a list of files that changed in the commit.
Here's the process that I would use:
svn log -r{20100101}:{20100331} -v --xml | xsltproc formatter.xsl -
And here's formatter.xsl:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xsd"
version="1.0"
>
<xsl:output method="text" indent="no" />
<xsl:key name="paths-key" match="/log/logentry/paths" use="path" />
<xsl:template match="log/logentry">
<xsl:for-each select="paths/path[count(. | key('paths-key', paths/path)[1]) = 1]">
<xsl:sort select="text()"/>
-- <xsl:value-of select="text()" />
<xsl:for-each select="key('paths-key', .)/preceding-sibling::date">
<xsl:sort select="translate(text(), '-:.T','')"/>
<xsl:variable name="selectedDate" select="text()"/>
<xsl:value-of select="translate($selectedDate, 'T', ' ')"/><xsl:text>
</xsl:text>
<xsl:for-each select="following-sibling::msg">
* <xsl:variable name="msg" select="text()"/>
<xsl:variable name="date" select="preceding-sibling::date/text()"/>
<xsl:if test="$selectedDate = $date">
<xsl:text> </xsl:text>
<xsl:value-of select="$msg"/>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
I imagine svn log --xml
and some sort of command-line XPath or XSLT is going to be your best bet.
With the command svn log
You probably need something more than just SVN to accomplish this programmatically. If .Net is not a problem, I recommend SharpSVn. The code below should get you somewhat started.
var la = new SvnLogArgs { Start = 16077, End = 17445 };
Collection<SvnLogEventArgs> list;
client.GetLog(new Uri(_respositoryPath), la, out list);
foreach (SvnLogEventArgs a in list)
{
// ...jazz
}
精彩评论