2010-06-04 81 views

回答

7

我不知道有什么办法可以使用纯粹的Subversion来做到这一点。但你可以做到这一点with sed

svn log | sed -n '/username/,/-----$/ p' 

此发现的用户名的每个实例,然后打印的一切行动,以虚线这标志着在日志中记录的末尾。

搜索模式非常灵活 - 您可以轻松修改它以搜索其他内容。例如,

svn log | sed -n '/Dec 2009/,/-----$/ p' 

会返回在12月(任何作者)提交的所有提交。

编辑:如果你不想实际提交信息,而只是总结的元数据,那么你可以只使用grep,以类似的方式威廉Leara的Windows answer

svn log | grep username 
+1

为什么在sed命令在p之前的空间? – Daniel 2013-02-12 16:00:36

+0

/和p之间的空格被sed忽略;有些人可能会发现不同的格式更容易阅读。 – 2015-11-24 12:36:55

2

的Windows版本:

svn log | find "William_Leara" 

输出看起来像:

r11506 | William_Leara | 2009-12-23 19:29:12 -0600 (Wed, 23 Dec 2009) | 12 lines 
r11505 | William_Leara | 2009-12-23 15:18:37 -0600 (Wed, 23 Dec 2009) | 12 lines 
r11504 | William_Leara | 2009-12-22 19:16:12 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11503 | William_Leara | 2009-12-22 19:04:15 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11502 | William_Leara | 2009-12-22 18:49:33 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11501 | William_Leara | 2009-12-22 18:26:45 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11500 | William_Leara | 2009-12-22 18:05:04 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11499 | William_Leara | 2009-12-22 17:25:25 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11498 | William_Leara | 2009-12-22 17:03:18 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11497 | William_Leara | 2009-12-22 16:54:59 -0600 (Tue, 22 Dec 2009) | 12 lines 
r11494 | William_Leara | 2009-12-21 14:36:20 -0600 (Mon, 21 Dec 2009) | 12 lines 
r11491 | William_Leara | 2009-12-19 12:48:49 -0600 (Sat, 19 Dec 2009) | 12 lines 

+1

这相当于'svn log | grep'William_Leara''在Unix中。我没有考虑过OP可能只是想要元数据。我的答案中的sed解决方案也提取了提交消息,这可能是也可能不是他想要的。 – 2010-06-04 22:23:17

4

如果你不介意阅读日志以XML格式,这里是如何与XML Starlet

svn log --xml --verbose <directory> | xmlstarlet sel -t -m "/log/logentry/author[text()='<wanted author>']/.." -c "." 

如果你不想被列出的那些文件,删除--verbose

下面是没有详细信息的示例输出。

$ svn log --xml zfce | xmlstarlet sel -t -m "/log/logentry/author[text()='pekka.jarvinen']/.." -c "." 

<logentry revision="157"> 
<author>pekka.jarvinen</author> 
<date>2009-09-26T19:23:40.060050Z</date> 
<msg>fix</msg> 
</logentry><logentry revision="156"> 
<author>pekka.jarvinen</author> 
<date>2009-09-25T20:40:01.823746Z</date> 
<msg>Dojo files are now downloaded from Google. Also some XHTML JS fixes (CDATA to &lt;script&gt;).</msg> 
</logentry><logentry revision="155"> 
<author>pekka.jarvinen</author> 
<date>2009-09-25T17:28:14.501392Z</date> 
<msg>Added spans</msg> 
</logentry><logentry revision="154"> 
<author>pekka.jarvinen</author> 
<date>2009-09-25T17:21:17.375304Z</date> 
<msg>Changed behavior: default.css is now not used as base. CSS in .INI configuration is always loaded.</msg> 
</logentry><logentry revision="151"> 
<author>pekka.jarvinen</author> 
<date>2009-04-10T00:24:41.683379Z</date> 
<msg>Added more PHP and Apache information</msg> 
</logentry> 

... 
+1

最好的答案,imo – 2012-09-28 13:06:38

+0

迄今为止最强大的恕我直言,但我不能使xmlstarlet在流模式下工作,所以我必须剪切和关闭日志的标签。 – ATorras 2013-01-22 08:41:53

4

最简单的方法是使用Subversion 1.8+命令行客户端;它支持--search--search-and选项,允许您过滤svn log输出以仅显示与您指定的搜索模式相匹配的修订。

SVNBook 1.8 | svn log command-line reference

Subversion 1.8 Release Notes | svn log can filter log messages based on search terms.

例如,

搜索由用户萨利或哈里致力于修订:

$ svn log --search Sally --search Harry https://svn.example.com/repos/test 
------------------------------------------------------------------------ 
r1701 | Sally | 2011-10-12 22:35:30 -0600 (Wed, 12 Oct 2011) | 1 line 

Add a reminder. 
------------------------------------------------------------------------ 
r1564 | Harry | 2011-10-09 22:35:30 -0600 (Sun, 09 Oct 2011) | 1 line 

Merge r1560 to the 1.0.x branch. 
------------------------------------------------------------------------ 
$ 

搜索由用户萨利致力于修订/富/ bar/helloworld.cpp:

$ svn log --verbose --search Sally --search-and /foo/bar/helloworld.cpp https://svn.example.com/repos/test 
------------------------------------------------------------------------ 
r1555 | Sally | 2011-07-15 22:33:14 -0600 (Fri, 15 Jul 2011) | 1 line 
Changed paths: 
M /foo/bar/helloworld.cpp 

Typofix. 
------------------------------------------------------------------------ 
r1530 | Sally | 2011-07-13 07:24:11 -0600 (Wed, 13 Jul 2011) | 1 line 
Changed paths: 
M /foo/bar/helloworld.cpp 
M /foo/build 

Fix up some svn:ignore properties. 
------------------------------------------------------------------------ 
$ 

注意:您也可以使用TortoiseSVN's Revision Log Dialog执行搜索和过滤。

1

在Windows环境下使用UnxUtils版本的sed,我需要使用这些正则表达式来代替,匹配----在行,下次启动:

svn log | sed -n "/username/,/^----/p" 
相关问题