Question

I'm playing with SharpSvn and have to analyze folder in repository
and I need to know when some file has be created there,
not last modification date, but when it was created,

Do you have any idea how to do that?

I started with the following:

    Collection<SvnLogEventArgs> logitems;
    var c = client.GetLog(new Uri(server_path), out logitems);


    foreach (var i in logitems)
    {
        var properties = i.CustomProperties;
        foreach (var p in properties)
        {
             Console.WriteLine(p.ToString());
             Console.WriteLine(p.Key);
             Console.WriteLine(p.StringValue);
        }
    }

But I don't see any creation date there.
Does someone know where to get it?

Était-ce utile?

La solution

Looks like I can't do that. Here is how I solved this problem: I'm getting the time if it was the SvnChangeAction.Add. Here is the code (SvnFile is my own class, not from SharpSvn):

public static List<SvnFile> GetSvnFiles(this SvnClient client, string uri_path)
{
    // get logitems
    Collection<SvnLogEventArgs> logitems;
    client.GetLog(new Uri(uri_path), out logitems);

    var result = new List<SvnFile>();

    // get craation date for each
    foreach (var logitem in logitems.OrderBy(logitem => logitem.Time))
    {
        foreach (var changed_path in logitem.ChangedPaths)
        {
            string filename = Path.GetFileName(changed_path.Path);
            if (changed_path.Action == SvnChangeAction.Add)
            {
                result.Add(new SvnFile() { Name = filename, Created = logitem.Time });
            }
        }
    }

    return result;
}

Autres conseils

Slightly different code than the previous one:

    private static DateTime findCreationDate(SvnClient client, SvnListEventArgs item)
    {
        Collection<SvnLogEventArgs> logList = new Collection<SvnLogEventArgs>();
        if (item.BasePath != "/" + item.Name)
        {
            client.GetLog(new Uri(item.RepositoryRoot + item.BasePath + "/" + item.Name), out logList);
            foreach (var logItem in logList)
            {
                foreach (var changed_path in logItem.ChangedPaths)
                {

                    string filename = Path.GetFileName(changed_path.Path);
                    if (filename == item.Name && changed_path.Action == SvnChangeAction.Add)
                    {
                        return logItem.Time;                            
                    }
                }
            }
        }
        return new DateTime();
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top