Hello,
I'm using SVNKIT 1.8 with SVN 1.8.5 and the SVN protocol to attempt to add
files in bulk to my SVN repository. I would like to have one method for
adding and updating files and the below code successfully handles both when
using the FILE protocol since the editor.addFile(file, null, -1) throws an
SVNException. When I switch to the SVN protocol (desired protocol), the
editor.addFile(file, null, -1); doesn't throw an exception. Instead the
editor.closeEdit(); throws an exception which is not desired. Any ideas on
how to use one API for both adding and updating files?
public void addFiles(Map<String, String> data) throws Exception {
TreeSet<String> filesToCreate = new TreeSet<String>(data.keySet());
SVNRepository repo = null;
ISVNEditor editor = null;
try {
repo = openSession();
editor = repo.getCommitEditor("Adding files.", null);
editor.openRoot(-1);
for (String file : filesToCreate) {
try {
editor.addFile(file, null, -1);
} catch (SVNException e) {
editor.openFile(file, -1);
}
editor.applyTextDelta(file, null);
SVNDeltaGenerator gen = new SVNDeltaGenerator();
String checksum = gen.sendDelta(file, new
ByteArrayInputStream(data.get(file).getBytes()), editor, true);
editor.closeFile(file, checksum);
}
editor.closeEdit();
} catch (Exception ex) {
abort(editor);
throw new Exception(ex.toString(), ex);
} finally {
closeSession(repo);
}
}
--
View this message in context:
http://subversion.1072662.n5.nabble.com/One-API-to-handle-adding-and-updating-files-tp186109.html
Sent from the SVNKit - Users mailing list archive at Nabble.com.