I need to delete a file in the svn repository by using svn kit jar .
I tried
SVNFileUtil.deleteFile(new File("URL"));
It does not throw any error. but am not able to delete the file which i given in url.
my code:
repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
//create authentication data
ISVNAuthenticationManager authManager =
SVNWCUtil.createDefaultAuthenticationManager(
prop.getProperty("SVNusername"),
prop.getProperty("SVNpassword"));
repository.setAuthenticationManager(authManager);
//need to identify latest revision
long latestRevision = repository.getLatestRevision();
System.out.println("Repository Latest Revision: " + latestRevision);
//create client manager and set authentication
SVNClientManager ourClientManager = SVNClientManager.newInstance();
ourClientManager.setAuthenticationManager(authManager);
//use SVNUpdateClient to do the export
SVNCommitClient commitClient = ourClientManager.getCommitClient();
commitClient.setIgnoreExternals(false);
SVNFileUtil.deleteFile(new File(urln));
SVNCommitClient client = new SVNCommitClient(authManager, null);
SVNCommitInfo info;
@manuelcr is right, and alternatively you can use high level code:
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
try {
final SvnRemoteDelete remoteDelete = svnOperationFactory.createRemoteDelete();
remoteDelete.setSingleTarget(SvnTarget.fromURL(fileUrl));
remoteDelete.setCommitMessage("Delete a file from the repository");
final SVNCommitInfo commitInfo = remoteDelete.run();
if (commitInfo != null) {
final long newRevision = commitInfo.getNewRevision();
System.out.println("Removed a file, revision " + newRevision + " created");
}
} finally {
svnOperationFactory.dispose();
}
Have you tried using a CommitEditor?
In this link you have a description about how get one from your SVNRepository and use it for deleting an entry.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.