Como verificar se o arquivo está sob controle de origem no SharpSvn?
Pergunta
Oi eu uso C # e biblioteca SharpSvn. Eu gostaria de verificar se o arquivo está sob controle de origem antes de adicionar-lo com SvnClient.Add. Quando eu faço isso no arquivo que já está sob SVN do que eu recebo erro:. "Já está sob controle de versão"
Solução
This pretty well demonstrates how to do it using status
using(SvnClient client = new SvnClient())
{
SvnStatusArgs sa = new SvnStatusArgs();
sa.Depth = SvnDepth.Empty; // Adjust this to check direct files, or (recursive) directories etc
Collection<SvnStatusEventArgs> statuses;
client.GetStatus("c:\\somefile.txt", sa, out statuses);
Assert.That(statuses.Count, Is.EqualTo(1));
Assert.That(SvnStatus.NotVersioned, Is.EqualTo(statuses[0].LocalContentStatus));
}
Outras dicas
If you only want to know if the file is under source control you could use .Info()
/ .GetInfo()
. That method is generally faster as it doesn't have to check if the file has changed since it was checked out.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow