1

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。このコマンドは、revision、user、size、datetime、および filename の 5 つの列を出力します。の出力は次の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

これにより、種類、名前、およびコミットの 3 つの列を含む出力が生成されます。出力は次のとおりです。

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

私が見逃している変換は何ですか?

4

2 に答える 2

1

私はこの解決策を得るためにJPBlancの答えを適応させました:

([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                 
于 2012-06-15T15:46:26.207 に答える
1

あなたが試すことができます :

$a = $Output.lists.list.entry |  select  name,kind,@{N="author";E={$_.commit.author}},@{N="date";E={$_.commit.date}}

それから

$a | Sort-Object -Property date
于 2012-06-15T13:36:09.070 に答える