SharpSvn - Is File or Folder is under svn repository

171 views Asked by At

i intend to use SharpSvn methods such as 'add' and 'lock' for file or folder under SVN repository. if the file is not mapped i receive an error indication - 'the node ... is not found'. prior to SvnClient.Info() or SvnClient.Status(), how can i know the status of the file - is it or is it not added to SVN repository?

1

There are 1 answers

0
sartoris On

You can use the 'GetStatus' method:

    static bool IsInRepository(string filename)
    {
        bool isVersioned = false;
        using (SvnClient client = new SvnClient())
        {
            SvnStatusArgs sa = new SvnStatusArgs();
            sa.Depth = SvnDepth.Empty;
            sa.RetrieveAllEntries = true;

            Collection<SvnStatusEventArgs> statuses;
            client.GetStatus(filename, sa, out statuses);
            isVersioned = !statuses[0].LocalContentStatus.Equals(SvnStatus.NotVersioned);
        }
        return isVersioned;
    }