public void commitToSvn(SVNClientManager clientManager) throws SVNException { SVNCommitClient commitClient = clientManager.getCommitClient(); File fileToCheckin = new File("LocalDir/SampleFileFolder/SampleFile1"); boolean recursive = true; SVNCommitInfo importInfo = commitClient .doImport( fileToCheckin , SVNURL.parseURIDecoded("<path at which we want to check-in the file>"), "testing svn kit integration", recursive); System.out.println(importInfo.getNewRevision()); }
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(); }
public void printCommitInfo(SVNCommitInfo info) { if (info != null && info.getNewRevision() >= 0 && info != SVNCommitInfo.NULL) { getOut().println("Committed revision " + info.getNewRevision() + "."); if (info.getErrorMessage() != null && info.getErrorMessage().isWarning()) { getOut().println("\n" + info.getErrorMessage().getMessage()); } } }
public void printCommitInfo(SVNCommitInfo info) { if (info != null && info.getNewRevision() >= 0 && info != SVNCommitInfo.NULL) { getOut().println("Committed revision " + info.getNewRevision() + "."); if (info.getErrorMessage() != null && info.getErrorMessage().isWarning()) { getOut().println("\n" + info.getErrorMessage().getMessage()); } } }
public long commit(String[] path, String message, boolean recurse, boolean noUnlock) throws ClientException { if(path == null || path.length == 0){ return 0; } SVNCommitClient client = getSVNCommitClient(); File[] files = new File[path.length]; for (int i = 0; i < path.length; i++) { files[i] = new File(path[i]).getAbsoluteFile(); } try { if(myMessageHandler != null){ client.setCommitHandler(new ISVNCommitHandler(){ public String getCommitMessage(String cmessage, SVNCommitItem[] commitables) { CommitItem[] items = JavaHLObjectFactory.getCommitItems(commitables); return myMessageHandler.getLogMessage(items); } }); } return client.doCommit(files, noUnlock, message, !recurse, recurse).getNewRevision(); } catch (SVNException e) { throwException(e); } return -1; }
/** @return revision */ public long delete(String comment) throws SVNException { SVNCommitClient client; SVNCommitInfo info; client = root.getClientMananger().getCommitClient(); info = client.doDelete(new SVNURL[] { getSvnurl() }, comment); return info.getNewRevision(); }
/** @return revision */ public long delete(String comment) throws SVNException { SVNCommitClient client; SVNCommitInfo info; client = root.getClientMananger().getCommitClient(); info = client.doDelete(new SVNURL[] { getSvnurl() }, comment); return info.getNewRevision(); }
public static void main(String[] args) { ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john"); SVNClientManager manager = SVNClientManager.newInstance(); manager.setAuthenticationManager(authManager); SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient(); try { SVNCommitInfo info = commitClient.doMkDir(new SVNURL[] { SVNURL.parseURIEncoded("http://192.168.3.127/repository/koux/branches") }, "commitMessage", null, true); long newRevision = info.getNewRevision(); System.out.println(newRevision); } catch (SVNException e) { e.printStackTrace(); } }
public static void main(String[] args) { ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john"); SVNClientManager manager = SVNClientManager.newInstance(); manager.setAuthenticationManager(authManager); SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient(); try { SVNCommitInfo info = commitClient.doMkDir(new SVNURL[] { SVNURL.parseURIEncoded("http://192.168.3.127/repository/koux/trunk") }, "commitMessage", null, true); long newRevision = info.getNewRevision(); System.out.println(newRevision); } catch (SVNException e) { e.printStackTrace(); } }
public SVNCommitInfo closeEdit() throws SVNException { ISVNEditor wrappedEditor = getWrappedEditor(); if (!myIsRootOpened) { wrappedEditor.openRoot(myBaseRevision); } myCommitInfo = wrappedEditor.closeEdit(); if (myHandler != null) { SVNLogEntry logEntry = new SVNLogEntry(null, myCommitInfo.getNewRevision(), myCommitInfo.getAuthor(), myCommitInfo.getDate(), null); myHandler.handleLogEntry(logEntry); } return myCommitInfo; }
public SVNCommitInfo closeEdit() throws SVNException { ISVNEditor wrappedEditor = getWrappedEditor(); if (!myIsRootOpened) { wrappedEditor.openRoot(myBaseRevision); } myCommitInfo = wrappedEditor.closeEdit(); if (myHandler != null) { SVNLogEntry logEntry = new SVNLogEntry(null, myCommitInfo.getNewRevision(), myCommitInfo.getAuthor(), myCommitInfo.getDate(), null); myHandler.handleLogEntry(logEntry); } return myCommitInfo; }
public SVNCommitInfo closeEdit() throws SVNException { ISVNEditor wrappedEditor = getWrappedEditor(); if (!myIsRootOpened) { wrappedEditor.openRoot(myBaseRevision); } myCommitInfo = wrappedEditor.closeEdit(); if (myHandler != null) { SVNLogEntry logEntry = new SVNLogEntry(null, myCommitInfo.getNewRevision(), myCommitInfo.getAuthor(), myCommitInfo.getDate(), null); myHandler.handleLogEntry(logEntry); } return myCommitInfo; }
public SVNCommitInfo closeEdit() throws SVNException { ISVNEditor wrappedEditor = getWrappedEditor(); if (!myIsRootOpened) { wrappedEditor.openRoot(myBaseRevision); } myCommitInfo = wrappedEditor.closeEdit(); if (myHandler != null) { SVNLogEntry logEntry = new SVNLogEntry(null, myCommitInfo.getNewRevision(), myCommitInfo.getAuthor(), myCommitInfo.getDate(), null); myHandler.handleLogEntry(logEntry); } return myCommitInfo; }
private CommitInfo getCommitInfo(SVNCommitInfo commitInfo, SVNURL repositoryRoot) throws ParseException { return new CommitInfo(commitInfo.getNewRevision(), SVNDate.formatDate(commitInfo.getDate()), commitInfo.getAuthor(), getErrorMessageString(commitInfo.getErrorMessage()), getUrlString(repositoryRoot)); }
public long commit(String[] path, String message, int depth, boolean noUnlock, boolean keepChangelist, String[] changelists, Map revprops) throws ClientException { if (path == null || path.length == 0) { return 0; } SVNCommitClient client = getSVNCommitClient(); File[] files = new File[path.length]; for (int i = 0; i < path.length; i++) { files[i] = new File(path[i]).getAbsoluteFile(); } try { client.setCommitHandler(createCommitMessageHandler(false, false)); SVNDepth svnDepth = SVNDepth.fromID(depth); boolean recurse = SVNDepth.recurseFromDepth(svnDepth); SVNProperties revisionProperties = revprops == null ? null : SVNProperties.wrap(revprops); return client.doCommit(files, noUnlock, message, revisionProperties, changelists, keepChangelist, !recurse, svnDepth).getNewRevision(); } catch (SVNException e) { throwException(e); } finally { if (client != null) { client.setCommitHandler(null); } resetLog(); } return -1; }
public long commit(String[] path, String message, int depth, boolean noUnlock, boolean keepChangelist, String[] changelists, Map revprops) throws ClientException { if (path == null || path.length == 0) { return 0; } SVNCommitClient client = getSVNCommitClient(); File[] files = new File[path.length]; for (int i = 0; i < path.length; i++) { files[i] = new File(path[i]).getAbsoluteFile(); } try { client.setCommitHandler(createCommitMessageHandler(false, false)); SVNDepth svnDepth = SVNDepth.fromID(depth); boolean recurse = SVNDepth.recurseFromDepth(svnDepth); SVNProperties revisionProperties = revprops == null ? null : SVNProperties.wrap(revprops); return client.doCommit(files, noUnlock, message, revisionProperties, changelists, keepChangelist, !recurse, svnDepth).getNewRevision(); } catch (SVNException e) { throwException(e); } finally { if (client != null) { client.setCommitHandler(null); } resetLog(); } return -1; }
@Override public String call() throws DebianizingException { SvnClientManager clientManager = SubversionSCM.createClientManager(provider); try { SVNCommitPacket changeset = clientManager.getCommitClient().doCollectCommitItems(new File[] {new File(path)}, false, true, SVNDepth.INFINITY, null); if (changeset != SVNCommitPacket.EMPTY) { SVNCommitInfo commitInfo = clientManager.getCommitClient().doCommit(changeset, false, commitMessage); if (commitInfo.getErrorMessage() != null) { throw new DebianizingException(MessageFormat.format("Error while commiting <{0}>: {1}", path, commitInfo.getErrorMessage().toString())); } else { return Long.toString(commitInfo.getNewRevision()); } } else { throw new DebianizingException("There was nothing to commit."); } } catch (SVNException e) { throw new DebianizingException("SVNException: " + e.getMessage(), e); } finally { clientManager.dispose(); } } }
/** * @param revision * @param revisionProperties * @param editor * @throws SVNException */ public void handleEndRevision(long revision, SVNProperties revisionProperties, ISVNEditor editor) throws SVNException { editor.closeEdit(); if (mySyncEditor.getCommitInfo().getNewRevision() != revision) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Commit created rev {0} but should have created {1}", new Object[] { String.valueOf(mySyncEditor.getCommitInfo().getNewRevision()), String.valueOf(revision) }); SVNErrorManager.error(err, SVNLogType.FSFS); } SVNProperties existingProperties = myTargetRepository.getRevisionProperties(revision, null); SVNProperties filtered = new SVNProperties(); filterProperties(revisionProperties, filtered, false); SVNProperties normalizedProps = SVNAdminClient.normalizeRevisionProperties(filtered); myNormalizedRevPropsCount += normalizedProps.size(); int filteredCount = SVNAdminHelper.writeRevisionProperties(myTargetRepository, revision, filtered); SVNAdminHelper.removePropertiesNotInSource(myTargetRepository, revision, revisionProperties, existingProperties); myTargetRepository.setRevisionPropertyValue(0, SVNRevisionProperty.LAST_MERGED_REVISION, SVNPropertyValue.create(SVNProperty.toString(revision))); myTargetRepository.setRevisionPropertyValue(0, SVNRevisionProperty.CURRENTLY_COPYING, null); myAdminClient.handlePropertesCopied(filteredCount > 0, revision); }
public boolean svnMkDirs(SVNURL[] urls) { ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager("admin", "john"); SVNClientManager manager = SVNClientManager.newInstance(); manager.setAuthenticationManager(authManager); SVNCommitClient commitClient = SVNClientManager.newInstance().getCommitClient(); try { SVNCommitInfo info = commitClient.doMkDir(urls, "commitMessage", null, true); long newRevision = info.getNewRevision(); if (log.isDebugEnabled()) { if (newRevision >= 0) log.debug("commit successful: new revision = " + newRevision); else log.debug("no commits performed (commit operation returned new revision < 0)"); } System.out.println(newRevision); } catch (SVNException e) { log.error(e); return false; } return true; }
public boolean commitFileChangeOnLatestRevision(String newContent, String dirPath, String fileName) throws SVNException { String logMessage = "log message"; boolean success = true; if (repository != null) { String filePath = dirPath + "/" + fileName; ISVNEditor editor = repository.getCommitEditor(logMessage, null /* locks */, true /* keepLocks */, null /* mediator */); editor.openRoot(-1); editor.addDir(dirPath, null, -1); editor.addFile(filePath, null, -1); long fileRevision = getFileRevision(filePath); editor.openFile(filePath, fileRevision); editor.applyTextDelta(filePath, null); byte[] bytesUtf8 = StringUtils.getBytesUtf8(newContent); SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); String checksum = deltaGenerator.sendDelta(filePath, new ByteArrayInputStream(bytesUtf8), editor, true); editor.closeFile(filePath, checksum); editor.closeDir(); editor.closeDir(); SVNCommitInfo commitInfo = editor.closeEdit(); success = commitInfo.getNewRevision() != fileRevision; } return success; }