我想使用命令行查看特定用户所做的所有更改集。这可行吗?我查看了svn log
的文档,但不知道如何操作。
我不知道有什么方法可以使用纯Subversion来实现这一点。但是你可以使用sed
来完成:
svn log | sed -n '/username/,/-----$/ p'
svn log | sed -n '/Dec 2009/,/-----$/ p'
返回12月份所有提交记录(任何作者)。
编辑:如果您不想要实际的提交消息,而只需要摘要元数据,则可以使用grep
,类似于William Leara的Windows 答案中的方式:
svn log | grep username
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 <script>).</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>
...
--search
和--search-and
选项,允许您过滤svn log
输出,以仅显示与指定搜索模式匹配的修订版。
SVNBook 1.8 | svn log
命令行参考,
Subversion 1.8 Release Notes | 根据搜索词过滤日志消息的svn log
。
例如,$ 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.
------------------------------------------------------------------------
$
搜索用户 Sally 提交的对 /foo/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的版本日志对话框进行搜索和过滤。
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
etc.
svn log | grep 'William_Leara'
гҖӮжҲ‘жІЎжңүиҖғиҷ‘иҝҮOPеҸҜиғҪеҸӘжғіиҰҒе…ғж•°жҚ®гҖӮжҲ‘зҡ„зӯ”жЎҲдёӯзҡ„sed
и§ЈеҶіж–№жЎҲд№ҹжҸҗеҸ–дәҶжҸҗдәӨж¶ҲжҒҜпјҢиҝҷеҸҜиғҪжҳҜд»–жғіиҰҒзҡ„пјҢд№ҹеҸҜиғҪдёҚжҳҜгҖӮ - ire_and_curses