C# sharpsvn提交失败,缺少项
我正在尝试使用SharpSvn以编程方式将我的工作副本更改提交到存储库。不幸的是,我收到了以下错误消息:“提交期间出错:'SomeFile'计划添加,但丢失。”(请注意,我在此处删除了该文件的路径)。该文件是存在的,如果我使用TortoiseSVN提交更改,那么一切都会按预期进行 我的提交代码:C# sharpsvn提交失败,缺少项,c#,sharpsvn,C#,Sharpsvn,我正在尝试使用SharpSvn以编程方式将我的工作副本更改提交到存储库。不幸的是,我收到了以下错误消息:“提交期间出错:'SomeFile'计划添加,但丢失。”(请注意,我在此处删除了该文件的路径)。该文件是存在的,如果我使用TortoiseSVN提交更改,那么一切都会按预期进行 我的提交代码: // use throw on error, since it provides more information why the operation failed // mig
// 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);
}
//使用抛出错误,因为它提供了操作失败原因的更多信息
//由于异常处理,可能会稍微慢一点
SvnCommitArgs commitArgs=new SvnCommitArgs(){ThrowOnError=true,Depth=(SharpSvn.SvnDepth)Depth,LogMessage=LogMessage};
List committedItems=新列表();
SharpSvn.SvnCommitResult commitResult;
使用(var svnClient=new svnClient())
{
svnClient.Notify+=(发送方,notifyEventArgs)=>
{
开关(notifyEventArgs.Action)
{
案例SvnNotifyAction.CommitReplacedWithCopy:
Add(新元组(notifyEventArgs.FullPath,SvnCommitItemChangeType.ReplacedByCopy));
打破
案例SvnNotifyAction.CommittedCopy:
Add(新元组(notifyEventArgs.FullPath,SvnCommitItemChangeType.CopyAdded));
打破
案例SvnNotifyAction.CommitReplaced:
Add(新元组(notifyEventArgs.FullPath,SvnCommitItemChangeType.Replaced));
打破
案例SvnNotifyAction.committed删除:
Add(新元组(notifyEventArgs.FullPath,SvnCommitItemChangeType.Deleted));
打破
案例SvnNotifyAction.committed:
Add(新元组(notifyEventArgs.FullPath,SvnCommitItemChangeType.Added));
打破
案例SvnNotifyAction.CommitModified:
Add(新元组(notifyEventArgs.FullPath,SvnCommitItemChangeType.Modified));
打破
}
};
提交(itemPaths.ToList(),commitArgs,out commitResult);
}
我注意到:目录是用大写字母写的,但是错误消息显示的是小写字母
编辑:
错误消息(日志):
VictorVncore.DL.SvnCommitException:提交期间出错:“D:\TestManager\SysData\System”计划添加,但缺少-->SharpSvn.SvnWorkingCopyPathNotFoundException:提交失败(详细信息如下):-->SharpSvn.SvnWorkingCopyPathNotFoundException:“D:\Test\System”计划添加,但缺少
---内部异常堆栈跟踪的结束---
位于SharpSvn.SvnClientArgs.HandleResult(SvnClientContext客户端,SvnException错误,对象目标)
在SharpSvn.SvnClientArgs.HandleResult(SvnClientContext客户端,svn_error_t*error,对象目标)
在SharpSvn.SvnClient.Commit(ICollection1路径、SvnCommitArgs参数、SvnCommitResult&result)
在VictorSvnCore.DL.SvnClientFacade.Commit(IReadOnlyCollection
1 itemPaths,String logMessage,SvnDepth depth)由于SharpSvn区分大小写,因此必须使用确切的路径(如在文件系统上)。我用解决了我的问题,它允许检索准确的路径。另一种可能是来自SvnTools
class by的GetTruePath()
方法。我通过使用精确的路径解决了这些问题: