Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FSRepositoryFactory.setup();
- final File repoPath = new File(System.getProperty("java.io.tmpdir", "/tmp"), "repos");
- SVNFileUtil.deleteAll(repoPath, true);
- final SVNURL repoURL = FSRepositoryFactory.createLocalRepository(repoPath, null, false, false, false, false);
- System.out.println("Repository created at " + repoPath + ", using " + repoURL + " as repository root URL");
- System.out.println();
- final String userName = "foo";
- final String userPassword = "bar";
- final SVNRepository repository = SVNRepositoryFactory.create(repoURL);
- final ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(userName, userPassword);
- repository.setAuthenticationManager(authManager);
- final String path = "file";
- final byte[] data = "This is a new file".getBytes();
- final ISVNEditor editor = repository.getCommitEditor("log message", null);
- editor.openRoot(-1);
- editor.changeFileProperty(path, SVNProperty.MIME_TYPE, SVNPropertyValue.create("text/xml"));
- editor.addFile(path, null, -1);
- editor.applyTextDelta(path, null);
- final SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
- final String checksum = deltaGenerator.sendDelta(path, new ByteArrayInputStream(data), editor, true);
- editor.closeFile(path, checksum);
- editor.closeDir();
- final SVNCommitInfo commitInfo = editor.closeEdit();
- System.out.println("commit info: " + commitInfo.toString());
- System.out.println();
- final SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(true), authManager);
- final SVNLogClient logClient = manager.getLogClient();
- System.out.println("Running log on " + repoURL);
- System.out.println();
- logClient.doLog(repoURL, new String[]{path}, SVNRevision.UNDEFINED, SVNRevision.create(0), SVNRevision.HEAD, false, true, -1, new ISVNLogEntryHandler(){
- public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
- System.out.println(logEntry);
- }
- });
- System.out.println();
- final SVNWCClient wcClient = manager.getWCClient();
- final SVNURL fileURL = repoURL.appendPath(path, false);
- final SVNPropertyData propData = wcClient.doGetProperty(fileURL, SVNProperty.MIME_TYPE, SVNRevision.HEAD, SVNRevision.HEAD);
- System.out.println(SVNProperty.MIME_TYPE + " property on " + fileURL + " is " + propData.getValue());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement