0

I am using SharpSvn DLL in PowerShell. I've got as far as updating the working local copy, but how to print the modification in the command line, the way the svn update command works?

svn update command output

$es = New-Object 'System.Collections.Generic.Dictionary[string [SharpSvn.SvnUpdateResult]]
$result = New-Object -TypeName SharpSvn.SvnUpdateResult -ArgumentList $es, 0

$svnClient = New-Object SharpSvn.SvnClient
[boolean] $stat = $svnClient.Update([string]$localDir, [ref]$result)
if ($stat -eq "True") {
    Write-Host " ..Done" -ForegroundColor Green
    if ($result.HasRevision) {
        Write-Host -NoNewLine ' Revision: '
        Write-Host $result.Revision
    }

There is a piece of code which I found online, but it didn't helped.

SvnUpdateArgs ua = new SvnUpdateArgs();
ua.Notify += delegate(object sender, SvnNotifyEventArgs e)
        {
            Console.Write(e.Action);
            Console.WriteLine(e.FullPath);
        };
ua = New-Object SharpSvn.SvnUpdateArgs();
  • 1
    From your code I don't see where `$res` should come from, shouldn't it be `$result`? –  Dec 07 '18 at 15:07
  • Your first code snippet is both incomplete and broken. Please create a [mcve] and update your question with that. Also describe the actual as well as the desired behavior of that code. Your second code snippet is C# code, whereas `New-Object` (last statement, presumably added by you) is PowerShell code. You can't mix the two like that. – Ansgar Wiechers Dec 09 '18 at 15:47
  • With that said, SharpSvn is notoriously badly documented, and PowerShell integration is far more complicated than it should be due to the way the API is designed. It's quite possible that what you're trying to accomplish is not possible without embedding C# code in PowerShell. It's probably a lot simpler to just run the `svn` commandline client from PowerShell. – Ansgar Wiechers Dec 09 '18 at 15:50
  • Thanks for pointing out the writing mistakes. @AnsgarWiechers , svn command-line client is the best option, 'svn update' serves the purpose, but the requirement is to use the SharpSvn client with Powershell. I will check more regarding C# code embedding in powershell. Thanks guys for the help. – vishal sharma Dec 09 '18 at 22:57

0 Answers0