使用 SharpSVN 添加文件
我想使用 SharpSVN 将目录下的所有未版本控制的文件添加到 SVN。
我首先在命令行上尝试了常规的 svn 命令:
C:\temp\CheckoutDir> svn status -v
我看到了所有子目录、所有已签入的文件、一些标有“?”的新文件,没有任何带有“L”锁定指示的文件
C:\temp\CheckoutDir> svn add . --force
这会导致所有新文件都在子目录本身已经处于版本控制之下,需要添加。
我想使用 SharpSVN 做同样的事情。 我将一些额外的文件复制到同一目录中并运行此代码:
...
using ( SharpSvn.SvnClient svn = new SvnClient() )
{
SvnAddArgs saa = new SvnAddArgs();
saa.Force = true;
saa.Depth = SvnDepth.Infinity;
try
{
svn.Add(@"C:\temp\CheckoutDir\." , saa);
}
catch (SvnException exc)
{
Log(@"SVN Exception: " + exc.Message + " - " + exc.File);
}
}
但是引发了 SvnException:
- SvnException.Message: 工作副本 'C:\temp\CheckoutDir' 已锁定
- SvnException.File: ..\..\..\subversion \libsvn_wc\lock.c"
我的代码中没有其他 svnclient 实例正在运行, 我也尝试
svn.cleanup()
在添加之前拨打电话,但无济于事。
由于文档相当模糊;), 我想知道这里是否有人知道答案。
提前致谢!
扬
I would like to add all unversioned files under a directory to SVN using SharpSVN.
I tried regular svn commands on the command line first:
C:\temp\CheckoutDir> svn status -v
I see all subdirs, all the files that are already checked in, a few new files labeled "?", nothing with the "L" lock indication
C:\temp\CheckoutDir> svn add . --force
This results in all new files in the subdirs ,that are already under version control themselves, to be added.
I'd like to do the same using SharpSVN. I copy a few extra files into the same directory and run this code:
...
using ( SharpSvn.SvnClient svn = new SvnClient() )
{
SvnAddArgs saa = new SvnAddArgs();
saa.Force = true;
saa.Depth = SvnDepth.Infinity;
try
{
svn.Add(@"C:\temp\CheckoutDir\." , saa);
}
catch (SvnException exc)
{
Log(@"SVN Exception: " + exc.Message + " - " + exc.File);
}
}
But an SvnException is raised:
- SvnException.Message: Working copy 'C:\temp\CheckoutDir' locked
- SvnException.File: ..\..\..\subversion\libsvn_wc\lock.c"
No other svnclient instance is running in my code,
I also tried calling
svn.cleanup()
right before the Add, but to no avail.
Since the documentation is rather vague ;),
I was wondering if anyone here knew the answer.
Thanks in advance!
Jan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用我的工具 http://svncompletesync.codeplex.com/ 或将其作为示例。
它正是您所需要的。
Use this my tool http://svncompletesync.codeplex.com/ or take it as a sample.
It does exactly what you need.
我尝试了马尔科姆的工具,但现在无法运行它,因为它看起来已经有几年了,但是在查看源代码之后,看起来这确实是您需要用来将本地签出文件夹与SVN 中的一个:
I tried Malcolm's tool but couldn't get it to run now that it looks to be a few years old, but after looking at the source code it looks like this is really all you need to use to sync the local checked out folder with the one in SVN:
我认为您不应该在路径后缀“,”。 尝试:
请在 SharpSvn 讨论板/邮件列表上进一步讨论这个问题,因为您看到的行为可能是一个错误。
I think you shouldn't suffix the path with a ','. Try:
Please do discuss this further on the SharpSvn discussion board/mailing list, because the behavior you are seeing might be a bug.