如何获取svn --xml list
命令的输出,并使用PowerShell将其转换为按提交日期时间排序的表?
我使用此命令输出工作区中每个文件的摘要:
svn --xml list svn://svn.example.com/Database
我收到以下输出:
<?xml version="1.0" encoding="UTF-8"?>
<lists>
<list
path="svn://svn.skyscanner.co.uk/SkyscannerDatabase/INT/Flightstore">
<entry
kind="dir">
<name>Assemblies</name>
<commit
revision="10768">
<author>sam</author>
<date>2011-03-03T17:35:40.705575Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Data</name>
<commit
revision="15118">
<author>yann</author>
<date>2012-06-07T17:52:46.028463Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Database Triggers</name>
<commit
revision="10764">
<author>sam</author>
<date>2011-03-03T16:31:50.399811Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Defaults</name>
<commit
revision="10764">
<author>sam</author>
<date>2011-03-03T16:31:50.399811Z</date>
</commit>
</entry>
<entry
kind="file">
<name>Filter.scpf</name>
<size>4396</size>
<commit
revision="14955">
<author>yann</author>
<date>2012-05-30T10:08:54.064942Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Functions</name>
<commit
revision="13994">
<author>sam</author>
<date>2012-03-12T10:41:18.173561Z</date>
</commit>
</entry>
<entry
kind="file">
<name>RedGate.ssc</name>
<size>0</size>
<commit
revision="10764">
<author>sam</author>
<date>2011-03-03T16:31:50.399811Z</date>
</commit>
</entry>
<entry
kind="file">
<name>RedGateDatabaseInfo.xml</name>
<size>2491</size>
<commit
revision="14546">
<author>david</author>
<date>2012-05-02T10:23:19.811375Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Rules</name>
<commit
revision="10768">
<author>sam</author>
<date>2011-03-03T17:35:40.705575Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Security</name>
<commit
revision="14956">
<author>yann</author>
<date>2012-05-30T10:11:38.387808Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Service Broker</name>
<commit
revision="10764">
<author>sam</author>
<date>2011-03-03T16:31:50.399811Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Storage</name>
<commit
revision="10764">
<author>sam</author>
<date>2011-03-03T16:31:50.399811Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Stored Procedures</name>
<commit
revision="15194">
<author>sam</author>
<date>2012-06-12T16:50:16.105896Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Synonyms</name>
<commit
revision="10764">
<author>sam</author>
<date>2011-03-03T16:31:50.399811Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Tables</name>
<commit
revision="15224">
<author>yann</author>
<date>2012-06-13T15:38:11.018172Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Types</name>
<commit
revision="10768">
<author>sam</author>
<date>2011-03-03T17:35:40.705575Z</date>
</commit>
</entry>
<entry
kind="dir">
<name>Views</name>
<commit
revision="15142">
<author>yann</author>
<date>2012-06-08T17:28:48.067359Z</date>
</commit>
</entry>
</list>
</lists>
该表应包含与svn --verbose list
命令的输出相同的列。该命令输出五列:修订版,用户,大小,日期时间和文件名。以下是svn --verbose list svn://svn.example.com/Database
的输出:
15224 yann Jun 13 16:38 ./
10768 sam Mar 03 2011 Assemblies/
15118 yann Jun 07 18:52 Data/
10764 sam Mar 03 2011 Database Triggers/
10764 sam Mar 03 2011 Defaults/
14955 yann 4396 May 30 11:08 Filter.scpf
13994 sam Mar 12 10:41 Functions/
10764 sam 0 Mar 03 2011 RedGate.ssc
14546 david 2491 May 02 11:23 RedGateDatabaseInfo.xml
10768 sam Mar 03 2011 Rules/
14956 yann May 30 11:11 Security/
10764 sam Mar 03 2011 Service Broker/
10764 sam Mar 03 2011 Storage/
15194 sam Jun 12 17:50 Stored Procedures/
10764 sam Mar 03 2011 Synonyms/
15224 yann Jun 13 16:38 Tables/
10768 sam Mar 03 2011 Types/
15142 yann Jun 08 18:28 Views/
我尝试过以下简单代码:
[Xml] $Output = svn --xml list svn://svn.example.com/Database
$Output.Lists.List.Entry
它产生三列输出:kind,name和commit。这是输出:
kind name commit
---- ---- ------
dir Assemblies commit
dir Data commit
dir Database Triggers commit
dir Defaults commit
file Filter.scpf commit
dir Functions commit
file RedGate.ssc commit
file RedGateDatabaseInfo.xml commit
dir Rules commit
dir Security commit
dir Service Broker commit
dir Storage commit
dir Stored Procedures commit
dir Synonyms commit
dir Tables commit
dir Types commit
dir Views commit
我遗失了哪些转变?
答案 0 :(得分:1)
您可以尝试:
$a = $Output.lists.list.entry | select name,kind,@{N="author";E={$_.commit.author}},@{N="date";E={$_.commit.date}}
然后
$a | Sort-Object -Property date
答案 1 :(得分:1)
我改编JPBlanc's answer以获得此解决方案:
([Xml] (svn list --xml svn://svn.example.com/Database)).Lists.List.Entry |
Select -Property @(
@{N='revision';E={$_.commit.GetAttribute('revision')}},
@{N='author'; E={$_.commit.author}},
'size',
@{N='date'; E={$_.commit.date}},
'name'
) |
Sort -Property date |
Format-Table -Auto
它产生以下输出:
revision author size date name
-------- ------ ---- ---- ----
10764 sam 0 2011-03-03T16:31:50.399811Z RedGate.ssc
10764 sam 2011-03-03T16:31:50.399811Z Storage
10764 sam 2011-03-03T16:31:50.399811Z Service Broker
10764 sam 2011-03-03T16:31:50.399811Z Defaults
10764 sam 2011-03-03T16:31:50.399811Z Synonyms
10764 sam 2011-03-03T16:31:50.399811Z Database Triggers
10768 sam 2011-03-03T17:35:40.705575Z Rules
10768 sam 2011-03-03T17:35:40.705575Z Types
10768 sam 2011-03-03T17:35:40.705575Z Assemblies
13994 sam 2012-03-12T10:41:18.173561Z Functions
14546 david 2491 2012-05-02T10:23:19.811375Z RedGateDatabaseInfo.xml
14955 yann 4396 2012-05-30T10:08:54.064942Z Filter.scpf
14956 yann 2012-05-30T10:11:38.387808Z Security
15118 yann 2012-06-07T17:52:46.028463Z Data
15142 yann 2012-06-08T17:28:48.067359Z Views
15194 sam 2012-06-12T16:50:16.105896Z Stored Procedures
15224 yann 2012-06-13T15:38:11.018172Z Tables