This page describes an approach to use XML tools for further processing of the output of cvs log . It is intended for
solve the problem of parsing CVS output only once
use xml tools to generate arbitrary reports
use xml tools to perform maintenance scripting
xschema for the output of cvs log
this is a sample xml representation for the output of cvs log . I will derive an Xschema and post it later. On the first hand, this is an example XML representation.
<?xml version="1.0" encoding="iso-8859-1"?>
<CvsLog>
<NonCvsFiles>
<NonCvsFile>001_MetaMorphosis.cvs.xml</NonCvsFile>
<NonCvsFile>cvskig,xsd.css</NonCvsFile>
<NonCvsFile>cvskig,xsd.ctm</NonCvsFile>
<NonCvsFile>cvskig,xsd.rld</NonCvsFile>
<NonCvsFile>cvskog,xsd</NonCvsFile>
<NonCvsFile>ext_protocol.dll</NonCvsFile>
<NonCvsFile>mmx_history</NonCvsFile>
<NonCvsFile>msvcr70.dll</NonCvsFile>
<NonCvsFile>x.log</NonCvsFile>
<NonCvsFile>x.xml</NonCvsFile>
</NonCvsFiles>
<RcsInfo
RcsFile="/home/cvs/001_MetaMorphosis/71_codeSnippets/13_mmcvs/cvslog.sf.mm,v"
WorkingFile="cvslog.sf.mm"
Head="1.6"
Branch=""
Locks="strict"
DefaultKopt="kv"
TotalRevisions="6"
SelectedRevisions="6">
<AccessList/>
<SymbolicNames>
<SymbolicName
Tag="hugo"
Rev="1.6"/>
</SymbolicNames>
<Revision
Rev="1.6"
Date="2003/04/14 19:52:09"
Author="beweiche"
State="Exp"
Add="37"
Del="1">added indented output
- wo auch immer
was ist
- null
revision 1.5
date: 2003/04/12 19:51:20; author: beweiche; state: Exp; lines: +5 -2
integrated call to cvs
</Revision>
<Revision
Rev="1.4"
Date="2003/04/12 12:24:10"
Author="beweiche"
State="Exp"
Add="46"
Del="7">iintegrated CVS such that simply a directory can be provided as input file
</Revision>
<Revision
Rev="1.3"
Date="2003/04/11 15:44:16"
Author="beweiche"
State="Exp"
Add="8"
Del="2">suppress whitespaced garbage
</Revision>
<Revision
Rev="1.2"
Date="2003/04/09 08:09:16"
Author="beweiche"
State="Exp"
Add="7"
Del="4">fixed two parse erros:
selected-versions may be separated by blanks
occasional apostrophe in production for symbolic names
</Revision>
<Revision
Rev="1.1"
Date="2003/03/29 22:15:59"
Author="beweiche"
State="Exp">initial import
</Revision>
</RcsInfo>
</CvsLog>
a parser for the output of cvs log
This is the grammar which generates an XML file according to the schema. It is implemented based on
MetaMorphosis. The following hints apply:
this is a set of production rules
the term ("description:\n" % ) indicates that the string "description:" must be in the input but is suppressed for the generated xml
the subjects of the production rules end up in xml elements (tags)
subjects starting with "_" do not appear as elements of its own (e.g. <_restline>
subjects starting with "@" are represented as attributes in xml
the full
MetaMorphosis script can be found here cvslog.sf.mm
<CvsLog> .
<CvsLog> = <NonCvsFiles> (<RcsInfo> | <_ws> | <garbage> ) * .
<NonCvsFiles> = <NonCvsFile> * .
<NonCvsFile> = ("? "%) <_restline> .
<garbage> =! ^[\n]? "\n".
<RcsInfo> =! <@RcsFile>
<@WorkingFile>
<@Head>
<@Branch>
<@Locks>
<AccessList>
<SymbolicNames>
<@DefaultKopt>
<@TotalRevisions> (";" [ \t]! % ) <@SelectedRevisions>
("description:\n" %)
<Revision>*
("=============================================================================\n" %)
.
<_restline> = ([ ]?%) ^[\n]? ("\n"%) .
<_ws> = ([ \n\t]! %) .
<@RcsFile> =! ("RCS file:" % ) <_restline> .
<@WorkingFile> =! ("Working file: "%) <_restline> .
<@Head> =! ("head:"%) <_restline> .
<@Branch> =! ("branch:"%) <_restline> .
<@Locks> =! ("locks:" %) <_restline> .
<AccessList> =! ("access list:" %) <_restline> .
<SymbolicNames> =! ("symbolic names:\n" %)
<SymbolicName> *
.
<SymbolicName> =! ([ \t]!%) <@Tag> <@Rev> .
<@Tag> =! ^[:]! .
<@DefaultKopt> =! ("keyword substitution:"%) <_restline> .
<@TotalRevisions> =! ("total revisions: "%) [0-9]! .
<@SelectedRevisions> =! ("selected revisions:"%) <_restline> .
<Revision> =! ("----------------------------\n" %)
<@Rev>
<@Date> (";"%)
<@Author> (";"%)
<@State> (";"%) <_lines>/
( ("\n"%))/
<_comment>/
.
<@Rev> =! (("revision" | ":") %) <_restline>. // production used in two different contexts
<@Date> =! ("date: "%) ^[;]! .
<@Author> =! ([ ]! "author: "%) ^[;]!.
<@State> =! ([ ]! "state: "%) ^[;]!.
<_lines> =! ([ ]! "lines: "%) <@Add> ([ ]! %)
<@Del> .
<@Add> =! ("+"%) [0-9]! .
<@Del> =! ("-"%) [0-9]! .
<_comment> =! ((^[\-\=] ^[\n]! "\n" ) |
( [\-\=]! ^[\n]! "\n" ) |
( "\n")
)* .

