Search code examples
c#sharpsvn

sharpsvn Commit fails with missing item


I am trying to use SharpSvn to programatically commit my working copy changes to a repository. Unfortunately, I receive the following error message: "Error during commit: 'SomeFile' is scheduled for addition, but is missing." (please note that I removed the path of the file here). The file is existing and if I use TortoiseSVN to commit the changes, everything works as expected.

My code for commiting:

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

What I have noticed: The directory is written in UpperCases but the error messages show lower cases.

Edit: The error message (log): VictorSvnCore.DL.SvnCommitException: Error during commit: 'D:\TestManager\SysData\System' is scheduled for addition, but is missing ---> SharpSvn.SvnWorkingCopyPathNotFoundException: Commit failed (details follow): ---> SharpSvn.SvnWorkingCopyPathNotFoundException: 'D:\Test\System' is scheduled for addition, but is missing --- End of inner exception stack trace --- at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, SvnException error, Object targets) at SharpSvn.SvnClientArgs.HandleResult(SvnClientContext client, svn_error_t* error, Object targets) at SharpSvn.SvnClient.Commit(ICollection1 paths, SvnCommitArgs args, SvnCommitResult& result) at VictorSvnCore.DL.SvnClientFacade.Commit(IReadOnlyCollection1 itemPaths, String logMessage, SvnDepth depth)


Solution

  • Since SharpSvn is case sensitive it is necessary to use the exact path (as on the file system). I solved my problem with this answer, which allows to retrieve the exact path. Another possibility might be the GetTruePath() method from the SvnTools class by SharpSvn.