Search code examples
c#svnhooksharpsvn

Get log details for a specific revision number in a post-commit hook with SharpSVN?


I'm trying to write a post-commit hook using SharpSVN but can't figure out how to get the changeset info using SharpSVN given the revision number and the path to the repo. Any ideas are much appreciated.


Solution

  • In hook clients you most likely want to use the SvnLookClient that directly accesses the repository. In this example (copied from another question here) I also use the SvnHookArguments class for parsing the hook arguments.

    static void Main(string[] args)
    {
      SvnHookArguments ha;
      if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PostCommit, false, out ha))
      {
        Console.Error.WriteLine("Invalid arguments");
        Environment.Exit(1);
      }
    
      using (SvnLookClient cl = new SvnLookClient())
      {
        SvnChangeInfoEventArgs ci;
        cl.GetChangeInfo(ha.LookOrigin, out ci);
    
        // ci contains information on the commit e.g.
        Console.WriteLine(ci.LogMessage); // Has log message
    
        foreach(SvnChangeItem i in ci.ChangedPaths)
        {
           //
        }
      }
    }