Hello Colin,
As I wrote here

http://lists.tmatesoft.com/pipermail/svnkit-users/2013-December/000855.html

The best you can do is to check for directory/file existence before calling 
getCommitEditor(). This 
won't give you 100% guarantee that operation will succeed, if someone exactly 
at the same time 
changes the same directory/file, but actually nothing will give you such a 
guarantee and often 
failing in this case is better than silent file/directory rewriting. If silent 
rewriting is more 
suitable for you, you can retry checkPath + committing several times until 
success.

SVNRepository#checkPath is a rather quick operation, if you reuse the same SVN 
connection (usuall 
connection establishing is the most time-consuming SVN operation). To reuse the 
same connection, 
checkPath() shouldn't be called between getCommitEditor() and 
closeEdit()/abortEdit(), better call 
it before.

--
Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge

> Hello,
> 
> I'm using SVNKIT 1.7.11 and SVN 1.8.5 and the SVN protocol to add
> directories to my repository.  I'm trying to allow my createDirectories API
> to gracefully handle the case where the directory being asked to be created
> already exists and not fail the whole bulk commit.
> 
> When using the SVN protocol the below exception is thrown/caught when the
> editor.closeEdit() line is executed.  When using the FILE protocol the
> below exception is thrown/caught when the  editor.addDir(folder, null, -1)
> line is executed and I can gracefully ignore that one bad folder add.
>  Since the SVN protocol doesn't throw the exception when the editor.addDir
> is called there is no way to ignore the exception without rolling back the
> whole bulk folder commit.  Any ideas on how to ignore the folder already
> exists error using the SVN protocol?
> 
> FILE Protocol Exception:
>     org.tmatesoft.svn.core.SVNException: svn: E175005: Path '/svn/repo/q/a'
> already exists
> 
> SVN Protocol Exception:
>     org.tmatesoft.svn.core.SVNException: svn: E160020: File already exists:
> filesystem '2de7b13c-0139-45f6-a121-4d8cc6918849', transaction '20-1e',
> path '/a'
> 
> Sample Data:
>     private Set<String> directoryList = new HashSet<String>() {
>         {
>           add("b/b1/b2/b3");
>           add("b/b1/b2");
>           add("b/b1");
>           add("a");
>           add("a/a1");
>           add("b");
>         }
>       };
> 
> SVNKIT API:
>     public void createDirectories(Set<String> data) throws Exception {
>         TreeSet<String> folderListToCreate = new TreeSet<String>(data);
>         SVNRepository repo = null;
>         ISVNEditor editor = null;
>         try {
>           repo = openSession();
>           editor = repo.getCommitEditor("Creating folders.", null);
>           editor.openRoot(-1);
>           for (String folder : folderListToCreate) {
>             try {
>               editor.addDir(folder, null, -1);
>               editor.closeDir();
>             } catch (SVNException ex) {
>               System.out.println("ignore exception");
>             }
>           }
>           editor.closeEdit();
>         } catch (Exception ex) {
>           abort(editor);
>           throw new Exception(ex.toString();
>         } finally {
>           closeSession(repo);
>         }
>       }

Reply via email to