Click here to Skip to main content
13,597,094 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi i have a problem using svn command in code behind :

public void SvnDiff(int rev1, int rev2)
        {
            try
            {
                var p = new Process();
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.FileName = "svn";
                string arg = string.Format("diff -r {0}:{1} --summarize --xml > SvnDiff.xml", rev1, rev2);
                Console.WriteLine(arg);
                p.StartInfo.Arguments = arg;
                p.Start();
                p.WaitForExit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }


When i use this command in cmd, it's working fine.
svn diff -r 2882:2888 --summarize --xml > SvnDiff.xml

but when i run my method i got this message:
svn: E020024: Error resolving case of '>'

What can i do right now to solve this ?
Thanks for any advice
Posted 28-Mar-13 12:24pm
Comments
Sergey Alexandrovich Kryukov 28-Mar-13 18:53pm
   
Pretty straightforward exception message, isn't it? You could easily find a solution just by looking at System.Diagnostic.Process documentation a bit more thoroughly...
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This is because of that pipe symbol, which is not valid for programmatic use of the shell's process start, which requires just the application or data file:
http://msdn.microsoft.com/en-us/library/53ezey2s.aspx[^].

Note that the pile is also not a part of command line arguments, that makes the problem.

Instead, remove the pipe and redirect the stream System.Diagnostics.Process.StandardInput (and, just in case, System.Diagnostics.Process.StandardError). You will find the code sample with redirection here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[^].

By the way, it will free you from creation of temporary file you tried to use for piping, which is always an extra hassle. You redirect the stream and do with redirected data whatever you want, parse it immediately, etc.

This will solve your problem. However, if our really need a "real" programming interface to Subversion, please see this CodeProject article: Accessing the Subversion repository from .NET using DotSVN[^].

It uses .NET library DotSVN:
http://en.wikipedia.org/wiki/DotSVN[^],
http://www.dotsvn.net/[^].

—SA
  Permalink  
v8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web02-2016 | 2.8.180621.3 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100