sharpsvn Commit 因缺少项目而失败
sharpsvn Commit fails with missing item
我正在尝试使用 SharpSvn 以编程方式将我的工作副本更改提交到存储库。不幸的是,我收到以下错误消息:"Error during commit: 'SomeFile' is scheduled for addition, but is missing."(请注意,我在这里删除了文件的路径)。该文件已存在,如果我使用 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);
}
我注意到:目录是用大写字母写的,但错误消息显示小写字母。
编辑:
错误信息(日志):
VictorSvnCore.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* 错误,对象目标)
在 SharpSvn.SvnClient.Commit(ICollection1 paths, SvnCommitArgs args, SvnCommitResult& result)
at VictorSvnCore.DL.SvnClientFacade.Commit(IReadOnlyCollection
1 itemPaths,字符串 logMessage,SvnDepth 深度)
由于 SharpSvn 区分大小写,因此有必要使用准确的路径(如在文件系统上)。我用 this answer, which allows to retrieve the exact path. Another possibility might be the GetTruePath()
method from the SvnTools
class by SharpSvn.
解决了我的问题
我正在尝试使用 SharpSvn 以编程方式将我的工作副本更改提交到存储库。不幸的是,我收到以下错误消息:"Error during commit: 'SomeFile' is scheduled for addition, but is missing."(请注意,我在这里删除了文件的路径)。该文件已存在,如果我使用 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);
}
我注意到:目录是用大写字母写的,但错误消息显示小写字母。
编辑:
错误信息(日志):
VictorSvnCore.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* 错误,对象目标)
在 SharpSvn.SvnClient.Commit(ICollection1 paths, SvnCommitArgs args, SvnCommitResult& result)
at VictorSvnCore.DL.SvnClientFacade.Commit(IReadOnlyCollection
1 itemPaths,字符串 logMessage,SvnDepth 深度)
由于 SharpSvn 区分大小写,因此有必要使用准确的路径(如在文件系统上)。我用 this answer, which allows to retrieve the exact path. Another possibility might be the GetTruePath()
method from the SvnTools
class by SharpSvn.