1

Hi all you clever people!

Given the revision number of any application in my SubVersion repository, how can I (using SharpSvn):

  1. Determine which application name the revision number identifies?
  2. Determine if it is a trunk or a branch revision?
  3. Determine the name of the branch (if it is a branch revision)?

My repository is organized this way:

Application1
    Trunk
        <Application files>
    Branches
        BranchName1
            <Application files> 
        BranchName2
            <Application files>
        ...
Application2
    Trunk
        <Application files>
    Branches
        BranchName1
            <Application files> 
        BranchName2
            <Application files>
        ...

I guess I should somehow retrieve the set of files that were changed with that specific revision number and then look at the Svn file paths?

Can it be done at all?

Martin Christiansen
  • 1,037
  • 3
  • 9
  • 28

1 Answers1

1

In SVN revision numbers are global for the whole repository, so there is not a "trunk revision". But what you can do to determine which paths have been affected by the revision, is run something like svn log -r<REV> --verbose.

In SharpSvn there are the methods SvnClient.LogMethod(Uri, SvnLogArgs, EventHandler<SvnLogEventArgs>) which lets you specify an EventHandler that you could use to figure out the affected paths and SvnClient.GetLog(Uri, SvnLogArgs, out Collection<SvnLogEventArgs>) which gives you a collection of the log messages that you could use to figure out the affected paths.

http://docs.sharpsvn.net/current/html/M_SharpSvn_SvnClient_Log_4.htm

Small example (with GetLog()):

using (var client = new SvnClient())
            {
                SvnLogArgs logArgs = new SvnLogArgs();
                Collection<SvnLogEventArgs> logResults;
                if (client.GetLog(new Uri("RepositoryUri"), logArgs, out logResults))
                {
                    foreach (var logResult in logResults)
                    {
                        if (logResult.ChangedPaths.Contains("searchedPath"))
                        {
                            // do something with the information
                        }
                    }
                }                    
                return;
            }
royalTS
  • 603
  • 4
  • 22
  • 2
    You can improve your answer by adding a simple example for OP and future users. Your answer should be self-contained, so that if the link you point to goes away, your answer still remains useful. – code_dredd Jul 24 '17 at 10:17