2015-10-05 40 views
0

我希望这不是太模糊。我正在编写一个应用程序在我们的SVN服务器上执行后提交挂钩。当我请求存储库URI时,我有时会得到与我的提交路径不匹配的答案。为什么我的SharpSVN客户端只返回存储库URI的一部分?

下面是如何获得一般提交ARGS(编辑以添加更多细节):

public Collection<SvnLogEventArgs> GetCommitArgs(string strUri, long lngRevision) 
{ 
    try 
     { 
      using (SvnClient client = new SvnClient()) 
      { 
       SvnLogArgs args = new SvnLogArgs(); 
       Collection<SvnLogEventArgs> col; 
       args.Start = lngRevision; 
       args.End = lngRevision; 
       bool bolGotLog = client.GetLog(new Uri(strUri), args, out col); 
       return col; 
      } 
     } 
     catch 
     { 
      return null; 
     } 
    } 

但这里是我应得的回购URI(GetRepository()基本上只是重新格式化它看起来像一个URL):

colCommitArgs = GetCommitArgs(args[0], long.Parse(args[1])); 
strRepository = GetRepository(args[0] + "/" + colCommitArgs[0].ChangedPaths[0].RepositoryPath.ToString()); 

args[0]实际上是指一组从呈交传递参数的个数。我发现ChangedPaths有时是空的。

例如,如果我提交到C:/Repositories/a_repo/somefolder/example.txt,我从SVN commit args返回的值仅为C:/Repositories/a_repo/。这可能是我们的SVN设置的一个问题(或者我对此不了解)。为什么有些文件夹被视为存储库,其他文件夹只是考虑文件夹?有没有办法指定一个文件夹不只是一个文件夹?或者在SharpSVN中有不同的方式来获取已提交的文件夹?我目前在原始URI的末尾连接了ChangedPaths[0].RepositoryPath

+0

你的代码并不真正对应你的问题的文字。请显示给出'C:/ Repositories/a_repo /'的代码,并显示连接ChangedPaths [0] .RepositoryPath'的代码。 –

+0

我添加了额外的代码。谢谢! – mrcoulson

+0

。除非通过可选的SvnLogArgs对象将.RetrievePaths传递为true,否则,ChangedPaths将为null。 –

回答

0

我不太了解您使用的C#库,但从通用的Subversion角度来看,您通常需要使用两个不同的版本号来查看更改。尝试使用args.Start = lngRevision - 1;,看看会发生什么。

相关问题