return doCommit(commitPackets, keepLocks, false, commitMessage, null);
/** * Committs local changes made to the Working Copy items to the repository. * * <p> * This method is identical to * <code>doCommit(commitPacket, keepLocks, false, commitMessage, null)</code>. * * <p> * <code>commitPacket</code> contains commit items ({@link SVNCommitItem}) * which represent local Working Copy items that were changed and are to be * committed. Commit items are gathered into a single * {@link SVNCommitPacket} by invoking * {@link #doCollectCommitItems(File[], boolean, boolean, boolean) * doCollectCommitItems()}. * * @param commitPacket * a single object that contains items to be committed * @param keepLocks * if <span class="javakeyword">true</span> and there are local * items that were locked then the commit will left them locked, * otherwise the items will be unlocked after the commit succeeds * @param commitMessage * a string to be a commit log message * @return information on a new revision as the result of the commit * @throws SVNException * @see SVNCommitItem */ public SVNCommitInfo doCommit(SVNCommitPacket commitPacket, boolean keepLocks, String commitMessage) throws SVNException { return doCommit(commitPacket, keepLocks, false, commitMessage, null); }
return clientManager.doCommit( paths, keepLocks, commitMessage, false, recursive );
/** * Committs local changes made to the Working Copy items to the repository. * * <p> * This method is identical to <code>doCommit(commitPacket, keepLocks, false, commitMessage, null)</code>. * * <p> * <code>commitPacket</code> contains commit items ({@link SVNCommitItem}) * which represent local Working Copy items that were changed and are to be committed. * Commit items are gathered into a single {@link SVNCommitPacket} * by invoking {@link #doCollectCommitItems(File[], boolean, boolean, boolean) doCollectCommitItems()}. * * @param commitPacket a single object that contains items to be committed * @param keepLocks if <span class="javakeyword">true</span> and there are local items that * were locked then the commit will left them locked, * otherwise the items will be unlocked after the commit * succeeds * @param commitMessage a string to be a commit log message * @return information on a new revision as the result * of the commit * @throws SVNException * @see SVNCommitItem */ public SVNCommitInfo doCommit(SVNCommitPacket commitPacket, boolean keepLocks, String commitMessage) throws SVNException { return doCommit(commitPacket, keepLocks, false, commitMessage, null); }
/** * Committs local changes made to the Working Copy items to the repository. * * <p> * This method is identical to <code>doCommit(commitPacket, keepLocks, false, commitMessage, null)</code>. * * <p> * <code>commitPacket</code> contains commit items ({@link SVNCommitItem}) * which represent local Working Copy items that were changed and are to be committed. * Commit items are gathered into a single {@link SVNCommitPacket} * by invoking {@link #doCollectCommitItems(File[], boolean, boolean, boolean) doCollectCommitItems()}. * * @param commitPacket a single object that contains items to be committed * @param keepLocks if <span class="javakeyword">true</span> and there are local items that * were locked then the commit will left them locked, * otherwise the items will be unlocked after the commit * succeeds * @param commitMessage a string to be a commit log message * @return information on a new revision as the result * of the commit * @throws SVNException * @see SVNCommitItem */ public SVNCommitInfo doCommit(SVNCommitPacket commitPacket, boolean keepLocks, String commitMessage) throws SVNException { return doCommit(commitPacket, keepLocks, false, commitMessage, null); }
return doCommit(commitPackets, keepLocks, false, commitMessage, null);
/** * Committs local changes to the repository. * * <p/> * This method is identical to <code>doCommit(paths, keepLocks, commitMessage, null, null, false, force, SVNDepth.fromRecurse(recursive))</code>. * * @param paths an array of local items which should be traversed * to commit changes they have to the repository * @param keepLocks if <span class="javakeyword">true</span> and there are local items that * were locked then the commit will left them locked, * otherwise the items will be unlocked after the commit * succeeds * @param commitMessage a string to be a commit log message * @param force <span class="javakeyword">true</span> to force a non-recursive commit; if * <code>recursive</code> is set to <span class="javakeyword">true</span> the <code>force</code> * flag is ignored * @param recursive relevant only for directory items: if <span class="javakeyword">true</span> then * the entire directory tree will be committed including all child directories, * otherwise only items located in the directory itself * @return information on a new revision as the result * of the commit * @throws SVNException * @deprecated use {@link #doCommit(File[], boolean, String, SVNProperties, String[], boolean, boolean, SVNDepth)} * instead */ public SVNCommitInfo doCommit(File[] paths, boolean keepLocks, String commitMessage, boolean force, boolean recursive) throws SVNException { return doCommit(paths, keepLocks, commitMessage, null, null, false, force, SVNDepth.getInfinityOrEmptyDepth(recursive)); }
return doCommit(paths, keepLocks, commitMessage, null, null, false, force, SVNDepth.fromRecurse(recursive));
/** * Committs local changes to the repository. * * <p/> * This method is identical to <code>doCommit(paths, keepLocks, commitMessage, null, null, false, force, SVNDepth.fromRecurse(recursive))</code>. * * @param paths an array of local items which should be traversed * to commit changes they have to the repository * @param keepLocks if <span class="javakeyword">true</span> and there are local items that * were locked then the commit will left them locked, * otherwise the items will be unlocked after the commit * succeeds * @param commitMessage a string to be a commit log message * @param force <span class="javakeyword">true</span> to force a non-recursive commit; if * <code>recursive</code> is set to <span class="javakeyword">true</span> the <code>force</code> * flag is ignored * @param recursive relevant only for directory items: if <span class="javakeyword">true</span> then * the entire directory tree will be committed including all child directories, * otherwise only items located in the directory itself * @return information on a new revision as the result * of the commit * @throws SVNException * @deprecated use {@link #doCommit(File[], boolean, String, SVNProperties, String[], boolean, boolean, SVNDepth)} * instead */ public SVNCommitInfo doCommit(File[] paths, boolean keepLocks, String commitMessage, boolean force, boolean recursive) throws SVNException { return doCommit(paths, keepLocks, commitMessage, null, null, false, force, SVNDepth.getInfinityOrEmptyDepth(recursive)); }
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager(); sam.setAuthenticationProvider(authProvider); SVNCommitClient commitClient = new SVNCommitClient(sam, null); buildListener.getLogger().println("[RELEASE] " + commitMessage); debuggingLogger.fine(String.format("Committing working copy: '%s'", workingCopy)); SVNCommitInfo commitInfo = commitClient.doCommit(new File[]{workingCopy}, true, commitMessage, null, null, true, true, SVNDepth.INFINITY); SVNErrorMessage errorMessage = commitInfo.getErrorMessage(); if (errorMessage != null) { throw new IOException("Failed to commit working copy: " + errorMessage.getFullMessage()); } return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed to Commit WorkingCopy", e); throw new IOException(e.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; }
SVNCommitInfo commitInfo = commitClient.doCommit(filesToCommit, // paths false, // keepLocks
/** * Method description * * * @param message * * @throws RepositoryClientException */ @Override public void commit(String message) throws RepositoryClientException { checkout(); SVNCommitClient cc = client.getCommitClient(); try { SVNCommitInfo info = cc.doCommit(pendingFiles.toArray(new File[0]), true, message, null, null, true, true, SVNDepth.INFINITY); SVNErrorMessage msg = info.getErrorMessage(); if (msg != null) { throw new RepositoryClientException(msg.getFullMessage()); } pendingFiles.clear(); } catch (SVNException ex) { throw new RepositoryClientException(ex); } }
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; }
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; }
private void commitWorkingCopy(String comment) throws Exception { SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject) null); svnm .getCommitClient() .doCommit(new File[] {new File(workingcopy.getRemote())}, false, comment, null, null, false, false, SVNDepth.INFINITY); svnm .getUpdateClient() .doUpdate(new File(workingcopy.getRemote()), SVNRevision.HEAD, SVNDepth.INFINITY, false, false); }
@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(); } } }
/** * Manufactures commits by adding files in the given names. */ private void createCommit(SubversionSCM scm, String... paths) throws Exception { FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); SvnClientManager svnm = SubversionSCM.createClientManager((AbstractProject)null); List<File> added = new ArrayList<>(); for (String path : paths) { FilePath newFile = b.getWorkspace().child(path); added.add(new File(newFile.getRemote())); if (!newFile.exists()) { newFile.touch(System.currentTimeMillis()); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); } else newFile.write("random content","UTF-8"); } SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(added.toArray(new File[added.size()]),false,"added",null,null,false,false,SVNDepth.EMPTY); }
@Test public void masterPolling() throws Exception { File repo = new CopyExisting(getClass().getResource("two-revisions.zip")).allocate(); SubversionSCM scm = new SubversionSCM("file://" + repo.toURI().toURL().getPath()); scm.setPollFromMaster(true); FreeStyleProject p = r.createFreeStyleProject(); p.setScm(scm); p.setAssignedLabel(r.createSlave().getSelfLabel()); r.assertBuildStatusSuccess(p.scheduleBuild2(2).get()); // initial polling on the master for the code path that doesn't find any change assertFalse(p.poll(StreamTaskListener.fromStdout()).hasChanges()); // create a commit FreeStyleProject forCommit = r.createFreeStyleProject(); forCommit.setScm(scm); forCommit.setAssignedLabel(r.jenkins.getSelfLabel()); FreeStyleBuild b = r.assertBuildStatusSuccess(forCommit.scheduleBuild2(0).get()); FilePath newFile = b.getWorkspace().child("foo"); newFile.touch(System.currentTimeMillis()); SvnClientManager svnm = SubversionSCM.createClientManager(p); svnm.getWCClient().doAdd(new File(newFile.getRemote()),false,false,false, SVNDepth.INFINITY, false,false); SVNCommitClient cc = svnm.getCommitClient(); cc.doCommit(new File[]{new File(newFile.getRemote())},false,"added",null,null,false,false,SVNDepth.INFINITY); // polling on the master for the code path that doesn't find any change assertTrue(p.poll(StreamTaskListener.fromStdout()).hasChanges()); }