I am using SharpSvn library for accessing Subversion. I have the requirement of checking if a specific folder is part of the subversion repository.
After some googling, I found the below code -
SvnClient client = new SvnClient();
Collection<SvnStatusEventArgs> args2;
bool result1 = client.GetStatus(@"D:\SVNMapping\demo\trunk\NewFolder", new SvnStatusArgs(), out args2);
result1 is getting true but args2[0].Versioned value is returned as false. But, the above folder is versioned and I can confirm it based on the icon -
I am not sure what I am missing in this API usage or if the API itself is incorrect for my requirement.
Any help is highly appreciated.
If you only want to check if a directory is under version control, it will be easier to use svn info
. In SharpSvn you could do this e.g. like this:
/// <summary>
/// Checks whether the specified path is under version control or not.
/// </summary>
/// <remarks>
/// Internally, the "svn info" command is used (no network access required).
/// </remarks>
/// <param name="path">The path to check.</param>
/// <returns>True, if the path is under version control, else false.</returns>
private bool CheckIfPathIsUnderVersionControl(string path)
{
using (SvnClient svnClient = new SvnClient())
{
// use ThrowOnError = false to avoid exception in case the path does
// not point to a versioned item
SvnInfoArgs svnInfoArgs = new SvnInfoArgs() { ThrowOnError = false };
Collection<SvnInfoEventArgs> svnInfo;
return svnClient.GetInfo(SvnTarget.FromString(path), svnInfoArgs, out svnInfo);
}
}
If you would like to know in which repository the item is versioned, then you could return this information from the SvnInfoArgs
, too.
If you really want to use svn status
then you should have a look at this questions since it explains why the option RetrieveAllEntries
must be set in the SvnStatusArgs
options and here.