如何从SVN存储库获取分支的最高版本号?

时间:2012-11-16 12:29:34

标签: c# visual-studio-2008 sharpsvn

我正在使用此代码段从 svn 中查找最高版本号,但我的页面没有响应。它继续只搜索

using (SvnClient client = new SvnClient())
{
    SvnInfoEventArgs info;
    Uri repos = new Uri("svn://india01/repository/branches/mybranch1");
    client.GetInfo(repos, out info);
    lblMsg.Visible = true;
    lblMsg.Text = (string.Format("The last revision of {0} is {1}", 
           repos, info.Revision));
}

我想从位于mybranch1 svn 存储库中的svn://india01/repository/branches/mybranch1获取最高版本号。

1 个答案:

答案 0 :(得分:1)

这里我们需要将SharpSvn Api dll引用添加到c#项目中。 link for SharpSvn package downloadthen follow the below link for example 获取最高版本号的代码

SvnInfoEventArgs statuses;
SvnClient client = new SvnClient();
client.Authentication.Clear();//clear a previous authentication
client.Authentication.DefaultCredentials = 
    new System.Net.NetworkCredential("usr", "pass");
client.GetInfo("svn://india00/Repo/branches/xyz", out statuses);
int LastRevision = (int)statuses.LastChangeRevision;`

将引用添加为

using SharpSvn;
using System.Collections.Generic;
using System.Collections.ObjectModel;`