我正在尝试使用SharpSvn以编程方式将我的工作副本更改提交到存储库。不幸的是,我收到以下错误消息:"提交期间出错:' SomeFile'计划添加,但遗失。" (请注意我在这里删除了文件的路径)。该文件存在,如果我使用TortoiseSVN提交更改,一切都按预期工作。
我提交的代码:
// use throw on error, since it provides more information why the operation failed
// might slow down a little bit, because of the exception handling
SvnCommitArgs commitArgs = new SvnCommitArgs() { ThrowOnError = true, Depth = (SharpSvn.SvnDepth)depth, LogMessage = logMessage };
List<Tuple<string, SvnCommitItemChangeType>> committedItems = new List<Tuple<string, SvnCommitItemChangeType>>();
SharpSvn.SvnCommitResult commitResult;
using (var svnClient = new SvnClient())
{
svnClient.Notify += (sender, notifyEventArgs) =>
{
switch (notifyEventArgs.Action)
{
case SvnNotifyAction.CommitReplacedWithCopy:
committedItems.Add(new Tuple<string, SvnCommitItemChangeType>(notifyEventArgs.FullPath, SvnCommitItemChangeType.ReplacedByCopy));
break;
case SvnNotifyAction.CommitAddCopy:
committedItems.Add(new Tuple<string, SvnCommitItemChangeType>(notifyEventArgs.FullPath, SvnCommitItemChangeType.CopyAdded));
break;
case SvnNotifyAction.CommitReplaced:
committedItems.Add(new Tuple<string, SvnCommitItemChangeType>(notifyEventArgs.FullPath, SvnCommitItemChangeType.Replaced));
break;
case SvnNotifyAction.CommitDeleted:
committedItems.Add(new Tuple<string, SvnCommitItemChangeType>(notifyEventArgs.FullPath, SvnCommitItemChangeType.Deleted));
break;
case SvnNotifyAction.CommitAdded:
committedItems.Add(new Tuple<string, SvnCommitItemChangeType>(notifyEventArgs.FullPath, SvnCommitItemChangeType.Added));
break;
case SvnNotifyAction.CommitModified:
committedItems.Add(new Tuple<string, SvnCommitItemChangeType>(notifyEventArgs.FullPath, SvnCommitItemChangeType.Modified));
break;
}
};
svnClient.Commit(itemPaths.ToList(), commitArgs, out commitResult);
}
我注意到:目录是用UpperCases编写的,但错误信息显示的是较小的情况。
编辑:
错误消息(日志):
VictorSvnCore.DL.SvnCommitException:提交期间出错:&#39; D:\ TestManager \ SysData \ System&#39;计划添加,但缺少---&gt; SharpSvn.SvnWorkingCopyPathNotFoundException:提交失败(详情如下):---&gt; SharpSvn.SvnWorkingCopyPathNotFoundException:&#39; D:\ Test \ System&#39;计划添加,但遗失
---内部异常堆栈跟踪结束---
在SharpSvn.SvnClientArgs.HandleResult(SvnClientContext客户端,SvnException错误,对象目标)
在SharpSvn.SvnClientArgs.HandleResult(SvnClientContext客户端,svn_error_t *错误,对象目标)
在SharpSvn.SvnClient.Commit(ICollection 1 paths, SvnCommitArgs args, SvnCommitResult& result)
at VictorSvnCore.DL.SvnClientFacade.Commit(IReadOnlyCollection
1 itemPaths,String logMessage,SvnDepth depth)
答案 0 :(得分:1)
由于SharpSvn区分大小写,因此必须使用确切的路径(与文件系统一样)。我用this answer解决了我的问题,它允许检索确切的路径。另一种可能性可能是来自GetTruePath()
类的SvnTools
方法SharpSvn。