SvnLook 客户端专门针对在存储库挂钩中使用。它允许访问未提交的修订,因此需要其他参数。 (它是 'svnlook' 命令的 SharpSvn 等效项。如果您需要 'svn' 等效项,您应该查看 SvnClient)。
外观来源是:
* 存储库路径和事务名称
* 或存储库路径和修订号
例如在预提交挂钩中,修订尚未提交,因此您无法像通常那样通过公共 url 访问它。
文档说(在 pre-commit.tmpl 中):
# The pre-commit hook is invoked before a Subversion txn is
# committed. Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
SharpSvn 通过以下方式帮助您:
SvnHookArguments ha;
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PostCommit, false, out ha))
{
Console.Error.WriteLine("Invalid arguments");
Environment.Exit(1);
}
它会为您解析这些参数。 (在这种情况下非常简单,但是有更高级的钩子。并且钩子可以在较新的 Subversion 版本中接收新参数)。您需要的值在 ha 的 .LookOrigin 属性中。
如果您只想获取特定修订范围 (1234-4567) 的日志消息,则不应查看 SvnLookClient。
using(SvnClient cl = new SvnClient())
{
SvnLogArgs la = new SvnLogArgs();
Collection<SvnLogEventArgs> col;
la.Start = 1234;
la.End = 4567;
cl.GetLog(new Uri("http://svn.collab.net/repos/svn"), la, out col))
}