Is there any provision to parse svn comments along with date in source file...thank you in advance for your ideas
-
5I don't understand what you meanPekka– Pekka2011-12-12 09:28:53 +00:00Commented Dec 12, 2011 at 9:28
-
Actually i need to parse the svn comments or log message along with datewhen any cpp files are modified, to that particular cpp file itself during commit ,any ideas?priya– priya2011-12-12 09:36:52 +00:00Commented Dec 12, 2011 at 9:36
-
It sounds like you want to read each of the "commit" actions done in Subversion, and read from them the names of the files committed, and the datetime when it the commit was done. Is that correct?Shalom Craimer– Shalom Craimer2011-12-12 09:48:13 +00:00Commented Dec 12, 2011 at 9:48
-
sorry exactly i would like to Append SVN comments with following details in changed area of file (Comments entered,Date & Time,SVN ID)priya– priya2011-12-12 10:01:12 +00:00Commented Dec 12, 2011 at 10:01
2 Answers
Reading the other answers here and your comments, it reads like your trying to modify the source file during commit. This is actively discouraged; see http://svnbook.red-bean.com/en/1.5/svn.reposadmin.create.html#svn.reposadmin.create.hooks which has a big red warning box that states:
While hook scripts can do almost anything, there is one dimension in which hook script authors should show restraint: do not modify a commit transaction using hook scripts. While it might be tempting to use hook scripts to automatically correct errors, shortcomings, or policy violations present in the files being committed, doing so can cause problems. Subversion keeps client-side caches of certain bits of repository data, and if you change a commit transaction in this way, those caches become indetectably stale. This inconsistency can lead to surprising and unexpected behavior. Instead of modifying the transaction, you should simply validate the transaction in the pre-commit hook and reject the commit if it does not meet the desired requirements. As a bonus, your users will learn the value of careful, compliance-minded work habits.
However it sounds like what you really want to look at is svn:keywords. These allow you to embed metadata into the file at commit time. The only thing you can't do is embed the commit log message.
Effectively, this means you'd drop a line that contains this:
$Id$
into your source file, then set the property svn:keywords with a value of Id against that file, and SVN will auto-expand it on commit. There's a number of other special keywords as well; see http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html for all the details on how to use these.
8 Comments
svn:keywords in my answer, and that should answer that question. If it doesn't, and you've checked out the SVN manual that I've linked to, let me know what it is you don't understand.$Id$ turns into $Id: calc.c 148 2006-07-28 21:30:43Z sally $ within the source file (typically these are placed the header of the file). No, you can't prepend every modification within a file automatically with these. But users can use svn log or svn diff to see what the changes actually are. SVN provides you with all the tools, so I'm failing to see where the problem is. You need to explain why you're trying to achieve what you asking: unless we know the full picture, you're not going to get a better answer.You have different options (awk, xml parser) to parse svn log: see "Ever need to parse the svn log for files committed by a particular user since a certain date?"
You have here an example of a Perl script using the --xml option (with svn info but you can apply the same idea to svn log), and the XML::Twig library.