本文介绍了从svn更新之前,请检查本地目录是否是工作副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用c#编程提取svn存储库.我已经将Sharpsvn dll添加到我的项目中,并编写了以下代码

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);

我已经使用'client.checkout'方法签出,并且可以使用'client.update'方法进行更新.

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

假设我的机器上有文件夹服务".我最初是使用"client.checkout"将文件/文件夹检出到该文件夹​​中.

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?

推荐答案

您可以像这样确定目录是否为工作副本:

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;
    }
}

这篇关于从svn更新之前,请检查本地目录是否是工作副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 23:34