I am trying to write a simple app in C# for source controling database files using SharpSVN library and have some problem implementing atomic commits.
This is the workflow i have in mind:
- User changes some files in database locally
- Compares to source control and checks some of the changes for comiting
- Loop through all selected changes (could be: add file, modify, delete) and apply them to the SVN working copy
- If everything is succefully applied to working copy, call commit, else revert all
- If commit is unsucesfull revert all
I am adding files to local working copy by calling File.Copy(temporaryPath, workCopyPath) and then SvnClient.Add(workCopyPath)
I am adding modifications to local working copy by calling File.Copy(temporaryPath, workCopyPath)
I am removing files from local working copy by calling SvnClient.Delete(workCopyPath)
In case of error while applying changes to working copy i tried to revert to the state before changes by calling SvnClient.Revert(workCopyRoot) but that does not revert all changes (for example, added files are still in workin copy after revert).
If everything is ok after applying changes, i call SvnClient.Commit(workCopyRoot) to apply changes to remote repo.
Is this a proper way to apply changes to working copy or should i use something else? Should i monitor changes to working copy and revert them manually (without SvnClient) or i am just missing some parameter for the SvnClient.Revert() method?
Thanks in advance, any help is more than welcome