使用svn命令的问题 [英] problem using svn command

查看:140
本文介绍了使用svn命令的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我在后面的代码中使用svn命令时遇到问题:



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);
            }
        }





当我在cmd中使用此命令时,它工作正常。

svn diff -r 2882:2888 --summarize --xml> SvnDiff.xml



但是当我运行我的方法时我收到了这条消息:

svn:E020024:错误解决' '>''



我现在可以做些什么来解决这个问题?

感谢任何建议



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

推荐答案

这是因为该管道符号对于程序使用shell的进程启动无效,只需要应用程序或数据文件:

http://msdn.microsoft.com/en-us/library/53ezey2s.aspx [ ^ ]。



请注意,堆也不是命令行参数的一部分,这就产生了问题。



相反,删除管道并重定向流 System.Diagnostics.Process.StandardInput (以防万一,系统.Diagnostics.Process。 StandardError的)。你会在这里找到带有重定向的代码示例:

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx [ ^ ]。



顺便说一下,它将使您免于创建您尝试用于管道的临时文件,这总是一件额外的麻烦。您可以重定向流,并根据需要使用重定向数据,立即解析,等等。



这将解决您的问题。但是,如果我们真的需要Subversion的真实编程接口,请参阅此CodeProject文章:使用DotSVN从.NET访问Subversion存储库 [ ^ ]。



它使用.NET库DotSVN:

http://en.wikipedia.org/wiki/DotSVN [ ^ ],

http://www.dotsvn.net/ [ ^ ]。



-SA
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


这篇关于使用svn命令的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆