给定svn的以下xml输出(通过svn-log-xml):
<?xml version="1.0"?>
<log>
<logentry revision="111802">
<author>author1</author>
<date>2014-09-24T17:48:11.447209Z</date>
<paths>
<path kind="file" action="A">/project/trunk/subdir/TransactionInfo.java</path>
<path kind="file" action="A">/project/trunk/subdir/Validation.java</path>
</paths>
<msg>added the start to the new Validation tool </msg>
</logentry>
<logentry revision="111801">
<author>author2</author>
<date>2014-09-24T17:32:51.129605Z</date>
<paths>
<path kind="file" action="A">/project/dispatcher/branches/EUROPA/docs/somefile.txt</path>
<path kind="file" action="A">/project/dispatcher/branches/EUROPA/docs/plans.txt</path>
</paths>
<msg>add plan steps doc and jobs spreadsheet</msg>
</logentry>
</log>
我正试图产生这样的输出。请注意,正确的修订版下列出了正确的2个文件。
111802 | author1 | 2014-09-24T17:48:11.447209Z | added the start to the new Validation tool
/project/trunk/subdir/TransactionInfo.java
/project/trunk/subdir/Validation.java
111801 | author2 | 2014-09-24T17:32:51.129605Z | add plan steps doc and jobs spreadsheet
/project/dispatcher/branches/EUROPA/docs/somefile.txt
/project/dispatcher/branches/EUROPA/docs/plans.txt
我使用以下命令,但我从两个修订版中获取所有文件。我相信我的错误是在第二个-m参数?
xmlstarlet sel -T -t -m /log/logentry -v "concat(@revision,' | ',author,' | ',date,' | ',msg)" -n -m /log/logentry/paths -v "path" -n svnoutput.xml
111802 | author1 | 2014-09-24T17:48:11.447209Z | added the start to the new Validation tool
/project/trunk/subdir/TransactionInfo.java
/project/trunk/subdir/Validation.java
/project/dispatcher/branches/EUROPA/docs/somefile.txt
/project/dispatcher/branches/EUROPA/docs/plans.txt
111801 | author2 | 2014-09-24T17:32:51.129605Z | add plan steps doc and jobs spreadsheet
/project/trunk/subdir/TransactionInfo.java
/project/trunk/subdir/Validation.java
/project/dispatcher/branches/EUROPA/docs/somefile.txt
/project/dispatcher/branches/EUROPA/docs/plans.txt
作为我想分享的旁注,这产生了一个我发现非常有用的新摘要:
xmlstarlet sel -T -t -m /log/logentry -v "concat(@revision,' | ',author,' | ',date,' | ',msg)" -n svnoutput.xml
111802 | author1 | 2014-09-24T17:48:11.447209Z | added the start to the new Validation tool
111801 | author2 | 2014-09-24T17:32:51.129605Z | add plan steps doc and jobs spreadsheet
只需去掉多余的-m
,并将第二个值更改为paths/path
:
xmlstarlet sel -T -t -m /log/logentry
-v "concat(@revision,' | ',author,' | ',date,' | ',msg)"
-n
-v "paths/path"
-n svnoutput.xml