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