Check local directory is a working copy before updating from svn

时光怂恿深爱的人放手 提交于 2019-12-11 14:50:16

问题


I am working on extracting svn repository using c# programming. I have added sharpsvn dll to my project and wrote following code

string localFolder= @"C:\Users\Desktop\LocalFolder\Dev\Websites\Service";
SvnClient client = new SvnClient();

SvnUriTarget target = new SvnUriTarget(@"http://svn.user.com/svn/websites/Branches/InternalServices");

SvnInfoEventArgs info;

client.GetInfo(target, out info);

//Specify the repository root as Uri
//Console.WriteLine("Repository version: {0}", info.Revision);
Console.WriteLine("Started checking out. Please wait few minutes");

client.CheckOut(target, localFolder);                   
//client.Update(localFolder);

I have checked out using 'client.checkout' method and i can update using 'client.update' method.

Let say i have folder 'services' in my machine. I am checking out files/folders initially using 'client.checkout' to this folder.

Next time when i run the program it should update automatically without checkout. How can i know if the service folder has already done a checkout once and now it should update?


回答1:


You can determine whether a directory is a working copy like this:

public static bool IsWorkingCopy(string path)
{
    using (var client = GetSvnClient())
    {
        var uri = client.GetUriFromWorkingCopy(path);
        return uri != null;
    }
}


来源:https://stackoverflow.com/questions/12424149/check-local-directory-is-a-working-copy-before-updating-from-svn

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!