/** * Gets the SVN metadata for the given local workspace. * * @param workspace * The target to run "svn info". */ private SVNInfo parseSvnInfo(File workspace) throws SVNException { final SVNWCClient svnWc = manager.getWCClient(); return svnWc.doInfo(workspace,SVNRevision.WORKING); }
@Override public void add(final File file) throws Exception { wcClient.doAdd(file, false, false, false, SVNDepth.UNKNOWN, false, true); }
/** * Reverts all local changes made to a Working Copy item(s) thus * bringing it to a 'pristine' state. * * @param path a WC path to perform a revert on * @param recursive <span class="javakeyword">true</span> to * descend recursively (relevant for directories) * @throws SVNException if one of the following is true: * <ul> * <li><code>path</code> is not under version control * <li>when trying to revert an addition of a directory * from within the directory itself * </ul> * @see #doRevert(File[],boolean) * @deprecated use {@link #doRevert(File[], SVNDepth, Collection)} */ public void doRevert(File path, boolean recursive) throws SVNException { doRevert(new File[] { path }, SVNDepth.getInfinityOrEmptyDepth(recursive), null); }
private void addLocalParents(File path, ISVNEventHandler handler) throws SVNException { boolean created = path.mkdirs(); SVNWCClient wcClient = new SVNWCClient((ISVNAuthenticationManager) null, null); try { wcClient.setEventHandler(handler); wcClient.doAdd(path, false, false, true, SVNDepth.EMPTY, true, true); } catch (SVNException e) { if (created) { SVNFileUtil.deleteAll(path, true); } throw e; } }
public void propertyRemove(String path, String name, boolean recurse) throws ClientException { SVNWCClient client = getSVNWCClient(); try { client.doSetProperty(new File(path).getAbsoluteFile(), name, null, false, recurse, ISVNPropertyHandler.NULL); } catch (SVNException e) { throwException(e); } }
@Override public void delete(File testDefinitionDirectory) throws Exception { wcClient.doDelete(testDefinitionDirectory, true, false); }
@Override protected void preUpdate(ModuleLocation module, File local) throws SVNException, IOException { listener.getLogger().println("Reverting " + local + " ignoreExternals: " + module.isIgnoreExternalsOption()); final SVNWCClient svnwc = manager.getWCClient(); svnwc.setIgnoreExternals(module.isIgnoreExternalsOption()); svnwc.doRevert(new File[]{local.getCanonicalFile()}, getSvnDepth(module.getDepthOption()), null); } }
/** * Gets an item's versioned property from a repository and passes it to * a provided property handler. This method is useful when having no * Working Copy at all. * * @param url an item's repository location * @param propName an item's property name; if it's * <span class="javakeyword">null</span> then * all the item's properties will be retrieved * and passed to <code>handler</code> for * processing * @param pegRevision a revision in which the item is first looked up * @param revision a target revision * @param recursive <span class="javakeyword">true</span> to * descend recursively * @param handler a caller's property handler * @throws SVNException if <code>propName</code> starts * with the {@link org.tmatesoft.svn.core.SVNProperty#SVN_WC_PREFIX * svn:wc:} prefix * @deprecated use {@link #doGetProperty(SVNURL, String, SVNRevision, SVNRevision, SVNDepth, ISVNPropertyHandler)} instead */ public void doGetProperty(SVNURL url, String propName, SVNRevision pegRevision, SVNRevision revision, boolean recursive, ISVNPropertyHandler handler) throws SVNException { doGetProperty(url, propName, pegRevision, revision, SVNDepth.getInfinityOrEmptyDepth(recursive), handler); }
@Override public void init(RepositoryDefinition repo, File dir, ProjectTeamSettings teamSettings) throws Exception { config = repo; baseDirectory = dir; String predefinedUser = repo.getOtherAttributes().get(new QName("svnUsername")); String predefinedPass = repo.getOtherAttributes().get(new QName("svnPassword")); if (predefinedUser == null) { predefinedUser = SVNURL.parseURIEncoded(repo.getUrl()).getUserInfo(); } ISVNOptions options = SVNWCUtil.createDefaultOptions(true); ISVNAuthenticationManager authManager = new SVNAuthenticationManager(repo.getUrl(), predefinedUser, predefinedPass, teamSettings); ourClientManager = SVNClientManager.newInstance(options, authManager); if (baseDirectory.exists()) { ourClientManager.getWCClient().doCleanup(baseDirectory); ourClientManager.getWCClient().doRevert(new File[] { baseDirectory }, SVNDepth.fromRecurse(true), null); } }
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { log(listener, "Reverting working copy: " + workingCopy); ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager(); sam.setAuthenticationProvider(authProvider); SVNWCClient wcClient = new SVNWCClient(sam, null); wcClient.doRevert(new File[]{workingCopy}, SVNDepth.INFINITY, null); return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed Revert WorkingCopy ", e); throw new IOException(e.getMessage()); } } }
@Override public Optional<String> download(SVNRepository repository, String path) { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); getWCClient(repository).doGetFileContents( SVNUtils.toURL(repository.getUrl(path)), SVNRevision.HEAD, SVNRevision.HEAD, false, out ); return Optional.of( IOUtils.toString(out.toByteArray(), "UTF-8") ); } catch (SVNException | IOException ex) { return Optional.empty(); } }
/** * Cleans up a working copy. * This method is equivalent to a call to <code>doCleanup(path, false)</code>. * * @param path a WC path to start a cleanup from * @throws SVNException if one of the following is true: * <ul> * <li><code>path</code> does not exist * <li><code>path</code>'s parent directory * is not under version control * </ul> * @see #doCleanup(File, boolean) */ public void doCleanup(File path) throws SVNException { doCleanup(path, false); }
doResolve(path, depth, resolveContents, resolveProperties, true, conflictChoice);
public Void invoke(File ws, VirtualChannel channel) throws IOException, InterruptedException { File workingCopy = new File(ws, location.getLocalDir()).getCanonicalFile(); try { log(listener, "Cleanup working copy: " + workingCopy); ISVNAuthenticationManager sam = SVNWCUtil.createDefaultAuthenticationManager(); sam.setAuthenticationProvider(authProvider); SVNWCClient wcClient = new SVNWCClient(sam, null); wcClient.doCleanup(workingCopy); return null; } catch (SVNException e) { debuggingLogger.log(Level.FINE, "Failed Cleanup ", e); throw new IOException(e.getMessage()); } } }
public void run() throws SVNException { List targets = getSVNEnvironment().combineTargets(getSVNEnvironment().getTargets(), true); if (targets.isEmpty()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT); } SVNWCClient client = getSVNEnvironment().getClientManager().getWCClient(); if (!getSVNEnvironment().isQuiet()) { client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment())); } SVNDepth depth = getSVNEnvironment().getDepth(); if (depth == SVNDepth.UNKNOWN) { depth = SVNDepth.EMPTY; } for (Iterator ts = targets.iterator(); ts.hasNext();) { String targetName = (String) ts.next(); SVNPath target = new SVNPath(targetName); if (target.isFile()) { try { client.doResolve(target.getFile(), depth, SVNConflictChoice.MERGED); } catch (SVNException e) { SVNErrorMessage err = e.getErrorMessage(); getSVNEnvironment().handleWarning(err, new SVNErrorCode[] {err.getErrorCode()}, getSVNEnvironment().isQuiet()); } } } }
/** * Returns the current Working Copy min- and max- revisions as well as * changes and switch status within a single string. * * <p/> * This method is the same as <code>doGetWorkingCopyID(path, trailURL, false)</code>. * * @param path a local path * @param trailURL optional: if not <span class="javakeyword">null</span> * specifies the name of the item that should be met * in the URL corresponding to the repository location * of the <code>path</code>; if that URL ends with something * different than this optional parameter - the Working * Copy will be considered "switched" * @return brief info on the Working Copy or the string * "exported" if <code>path</code> is a clean directory * @throws SVNException if <code>path</code> is neither versioned nor * even exported * @see #doGetWorkingCopyID(File, String, boolean) */ public String doGetWorkingCopyID(final File path, String trailURL) throws SVNException { return doGetWorkingCopyID(path, trailURL, false); }
private void addLocalParents(File path, ISVNEventHandler handler) throws SVNException { boolean created = path.mkdirs(); SVNWCClient wcClient = new SVNWCClient((ISVNAuthenticationManager) null, null); try { wcClient.setEventHandler(handler); wcClient.doAdd(path, false, false, true, SVNDepth.EMPTY, true, true); } catch (SVNException e) { if (created) { SVNFileUtil.deleteAll(path, true); } throw e; } }
public void propertySet(String path, String name, String value, boolean recurse, boolean force) throws ClientException { SVNWCClient client = getSVNWCClient(); try { client.doSetProperty(new File(path).getAbsoluteFile(), name, value, force, recurse, ISVNPropertyHandler.NULL); } catch (SVNException e) { throwException(e); } }
@Override public void delete(File testDefinitionDirectory) throws Exception { wcClient.doDelete(testDefinitionDirectory, true, false); }
@Override protected void preUpdate(ModuleLocation module, File local) throws SVNException, IOException { listener.getLogger().println("Reverting " + local + " ignoreExternals: " + module.isIgnoreExternalsOption()); final SVNWCClient svnwc = manager.getWCClient(); svnwc.setIgnoreExternals(module.isIgnoreExternalsOption()); svnwc.doRevert(new File[]{local.getCanonicalFile()}, getSvnDepth(module.getDepthOption()), null); } }