private String update(SvnOperationFactory svnOperationFactory, String label) throws SVNException { logger.debug("Repo already checked out - updating instead."); try { final SvnUpdate update = svnOperationFactory.createUpdate(); update.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); long[] ids = update.run(); StringBuilder version = new StringBuilder(); for (long id : ids) { if (version.length() > 0) { version.append(","); } version.append(id); } return version.toString(); } catch (Exception e) { String message = "Could not update remote for " + label + " (current local=" + getWorkingDirectory().getPath() + "), remote: " + this.getUri() + ")"; if (logger.isDebugEnabled()) { logger.debug(message, e); } else if (logger.isWarnEnabled()) { logger.warn(message); } } final SVNStatus status = SVNClientManager.newInstance().getStatusClient() .doStatus(getWorkingDirectory(), false); return status != null ? status.getRevision().toString() : null; }
public static void canDelete(File path, ISVNOptions options, final ISVNEventHandler eventHandler) throws SVNException { SVNStatusClient statusClient = new SVNStatusClient((ISVNAuthenticationManager) null, options); if (eventHandler != null) { statusClient.setEventHandler(new ISVNEventHandler() { public void checkCancelled() throws SVNCancelException { eventHandler.checkCancelled(); } public void handleEvent(SVNEvent event, double progress) throws SVNException { } }); } statusClient.doStatus(path, SVNRevision.UNDEFINED, SVNDepth.INFINITY, false, false, false, false, new ISVNStatusHandler() { public void handleStatus(SVNStatus status) throws SVNException { if (status.getContentsStatus() == SVNStatusType.STATUS_OBSTRUCTED) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.NODE_UNEXPECTED_KIND, "''{0}'' is in the way of the resource actually under version control", status.getFile()); SVNErrorManager.error(err, SVNLogType.WC); } else if (status.getEntry() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNVERSIONED_RESOURCE, "''{0}'' is not under version control", status.getFile()); SVNErrorManager.error(err, SVNLogType.WC); } else if ((status.getContentsStatus() != SVNStatusType.STATUS_NORMAL && status.getContentsStatus() != SVNStatusType.STATUS_DELETED && status.getContentsStatus() != SVNStatusType.STATUS_MISSING) || (status.getPropertiesStatus() != SVNStatusType.STATUS_NONE && status.getPropertiesStatus() != SVNStatusType.STATUS_NORMAL)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MODIFIED, "''{0}'' has local modifications", status.getFile()); SVNErrorManager.error(err, SVNLogType.WC); } } }, null); }
/** * Returns an instance of the {@link SVNStatusClient} class. * * <p> * If it's the first time this method is being called the object is * created, initialized and then returned. Further calls to this * method will get the same object instantiated at that moment of * the first call. <b>SVNClientManager</b> does not reinstantiate * its <b>SVN</b>*<b>Client</b> objects. * * @return an <b>SVNStatusClient</b> instance */ public SVNStatusClient getStatusClient() { if (myStatusClient == null) { myStatusClient = new SVNStatusClient(this, myOptions); myStatusClient.setEventHandler(myEventHandler); myStatusClient.setDebugLog(getDebugLog()); myStatusClient.setIgnoreExternals(myIsIgnoreExternals); } return myStatusClient; }
public static void canDelete(File path, boolean skipIgnored, ISVNOptions options) throws SVNException { SVNStatusClient statusClient = new SVNStatusClient((ISVNAuthenticationManager) null, options); statusClient.doStatus(path, SVNRevision.UNDEFINED, true, false, false, !skipIgnored, false, new ISVNStatusHandler() { public void handleStatus(SVNStatus status) throws SVNException { if (status.getContentsStatus() == SVNStatusType.STATUS_OBSTRUCTED) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.NODE_UNEXPECTED_KIND, "''{0}'' is in the way of the resource actually under version control", status.getFile()); SVNErrorManager.error(err); } else if (status.getEntry() == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNVERSIONED_RESOURCE, "''{0}'' is not under version control", status.getFile()); SVNErrorManager.error(err); } else if ((status.getContentsStatus() != SVNStatusType.STATUS_NORMAL && status.getContentsStatus() != SVNStatusType.STATUS_DELETED && status.getContentsStatus() != SVNStatusType.STATUS_MISSING) || (status.getPropertiesStatus() != SVNStatusType.STATUS_NONE && status.getPropertiesStatus() != SVNStatusType.STATUS_NORMAL)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_MODIFIED, "''{0}'' has local modifications", status.getFile()); SVNErrorManager.error(err); } } }); }
SVNWCAccess wcAccess = createWCAccess(); SVNStatusEditor editor = null; final boolean[] deletedInRepository = new boolean[] {false}; externals = collectParentExternals(path, info.getAnchor().getRoot()); SVNRepository repository = createRepository(url, true); long rev; if (revision == SVNRevision.HEAD) { rev = -1; } else { rev = getRevisionNumber(revision, repository, path); checkCancelled(); if (kind == SVNNodeKind.NONE) { if (!entry.isScheduledForAddition()) { deletedInRepository[0] = true; editor = new SVNStatusEditor(getOptions(), wcAccess, info, includeIgnored, reportAll, recursive, realHandler); editor.setExternals(externals); checkCancelled(); editor.closeEdit(); } else { editor = new SVNRemoteStatusEditor(getOptions(), wcAccess, info, includeIgnored, reportAll, recursive, realHandler); editor.setExternals(externals); SVNRepository locksRepos = createRepository(url, false); checkCancelled(); SVNReporter reporter = new SVNReporter(info, path, false, recursive, getDebugLog()); SVNStatusReporter statusReporter = new SVNStatusReporter(locksRepos, reporter, editor);
public Status[] status(final String path, boolean descend, boolean onServer, boolean getAll, boolean noIgnore, boolean ignoreExternals) throws ClientException { if (path == null) { return null; } final Collection statuses = new ArrayList(); SVNStatusClient stClient = getSVNStatusClient(); boolean oldIgnoreExternals = stClient.isIgnoreExternals(); stClient.setIgnoreExternals(ignoreExternals); try { stClient.doStatus(new File(path).getAbsoluteFile(), descend, onServer, getAll, noIgnore, !ignoreExternals, new ISVNStatusHandler(){ public void handleStatus(SVNStatus status) { statuses.add(JavaHLObjectFactory.createStatus(status.getFile().getPath(), status)); } }); } catch (SVNException e) { throwException(e); } finally { stClient.setIgnoreExternals(oldIgnoreExternals); } return (Status[]) statuses.toArray(new Status[statuses.size()]); }
wcAccess.close(); SVNStatusClient statusClient = new SVNStatusClient((ISVNAuthenticationManager) null, getOptions()); statusClient.setIgnoreExternals(true); final long[] maxRevision = new long[1]; final long[] minRevision = new long[]{-1}; final boolean[] switched = new boolean[3]; final String[] wcURL = new String[1]; statusClient.doStatus(path, SVNRevision.WORKING, SVNDepth.INFINITY, false, true, false, false, new ISVNStatusHandler() { public void handleStatus(SVNStatus status) { if (status.getEntryProperties() == null || status.getEntryProperties().isEmpty()) {
public static SVNWCAccess createCommitWCAccess(File[] paths, boolean recursive, boolean force, Collection relativePaths, final SVNStatusClient statusClient) throws SVNException { String[] validatedPaths = new String[paths.length]; for (int i = 0; i < paths.length; i++) { statusClient.checkCancelled(); File file = paths[i]; validatedPaths[i] = SVNPathUtil.validateFilePath(file.getAbsolutePath()); boolean lockAll = false; if (relativePaths.isEmpty()) { statusClient.checkCancelled(); String target = getTargetName(baseDir); if (!"".equals(target)) { statusClient.checkCancelled(); String targetPath = (String) targets.next(); File targetFile = new File(baseDir, targetPath); baseAccess.setOptions(statusClient.getOptions()); try { baseAccess.open(baseDir, true, lockAll ? SVNWCAccess.INFINITE_DEPTH : 0); statusClient.checkCancelled(); dirsToLock = new ArrayList(dirsToLock); dirsToLockRecursively = new ArrayList(dirsToLockRecursively); removeRedundantPaths(dirsToLockRecursively, dirsToLock); for (Iterator nonRecusivePaths = dirsToLock.iterator(); nonRecusivePaths.hasNext();) { statusClient.checkCancelled(); String path = (String) nonRecusivePaths.next(); File pathFile = new File(baseDir, path);
SVNStatusClient client = getSVNEnvironment().getClientManager().getStatusClient(); if (!getSVNEnvironment().isXML()) { client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment())); long rev = client.doStatus(commandTarget.getFile(), revision, getSVNEnvironment().getDepth(), getSVNEnvironment().isUpdate(), getSVNEnvironment().isVerbose(), getSVNEnvironment().isNoIgnore(),
SVNStatusClient statusClient = new SVNStatusClient(getRepositoryPool(), getOptions()); statusClient.setEventHandler(new ISVNEventHandler() { public void handleEvent(SVNEvent event, double progress) throws SVNException {
/** * Returns an instance of the {@link SVNStatusClient} class. * * <p> * If it's the first time this method is being called the object is * created, initialized and then returned. Further calls to this * method will get the same object instantiated at that moment of * the first call. <b>SVNClientManager</b> does not reinstantiate * its <b>SVN</b>*<b>Client</b> objects. * * @return an <b>SVNStatusClient</b> instance */ public SVNStatusClient getStatusClient() { if (myStatusClient == null) { myStatusClient = new SVNStatusClient(this, myOptions); myStatusClient.setEventHandler(myEventHandler); myStatusClient.setDebugLog(getDebugLog()); } return myStatusClient; }
myStatusClient.setEventHandler(handler);
myStatusClient.setIgnoreExternals(myIsIgnoreExternals);
myStatusClient.setDebugLog(log);
final Collection<String> changeLists) throws SVNException { final SvnGetStatus getStatus = getOperationsFactory().createGetStatus(); getStatus.setReportExternals(!isIgnoreExternals()); getStatus.setFileListHook(SvnCodec.fileListHook(myFilesProvider)); getStatus.setApplicalbeChangelists(changeLists);
/** * Returns an instance of the {@link SVNStatusClient} class. * * <p> * If it's the first time this method is being called the object is * created, initialized and then returned. Further calls to this * method will get the same object instantiated at that moment of * the first call. <b>SVNClientManager</b> does not reinstantiate * its <b>SVN</b>*<b>Client</b> objects. * * @return an <b>SVNStatusClient</b> instance */ public SVNStatusClient getStatusClient() { if (myStatusClient == null) { myStatusClient = myOperationFactory != null ? new SVNStatusClient(myOperationFactory) : new SVNStatusClient(this, myOptions); initClientDefaults(myStatusClient); } return myStatusClient; }
SVNWCAccess wcAccess = createWCAccess(); SVNStatusEditor editor = null; final boolean[] deletedInRepository = new boolean[] {false}; SVNRepository repository = createRepository(url, anchor.getRoot(), wcAccess, true); long rev; if (revision == SVNRevision.HEAD) { rev = -1; } else { rev = getRevisionNumber(revision, repository, path); checkCancelled(); SVNReporter reporter = null; if (kind == SVNNodeKind.NONE) { editor = new SVNStatusEditor(getOptions(), wcAccess, info, includeIgnored, reportAll, depth, realHandler); checkCancelled(); editor.closeEdit(); } else { editor = new SVNRemoteStatusEditor(getOptions(), wcAccess, info, includeIgnored, reportAll, depth, realHandler); SVNRepository locksRepos = createRepository(url, anchor.getRoot(), wcAccess, false); checkCancelled(); boolean serverSupportsDepth = repository.hasCapability(SVNCapability.DEPTH); reporter = new SVNReporter(info, path, false, !serverSupportsDepth, depth, false, true, true, getDebugLog()); SVNStatusReporter statusReporter = new SVNStatusReporter(locksRepos, reporter, editor);
private void status(String path, int depth, boolean onServer, boolean getAll, boolean noIgnore, boolean ignoreExternals, String[] changelists, ISVNStatusHandler handler) throws ClientException { if (path == null) { return; } SVNStatusClient stClient = getSVNStatusClient(); boolean oldIgnoreExternals = stClient.isIgnoreExternals(); stClient.setIgnoreExternals(ignoreExternals); try { stClient.doStatus(new File(path).getAbsoluteFile(), SVNRevision.HEAD, JavaHLObjectFactory.getSVNDepth(depth), onServer, getAll, noIgnore, !ignoreExternals, handler, JavaHLObjectFactory.getChangeListsCollection(changelists)); } catch (SVNException e) { throwException(e); } finally { stClient.setIgnoreExternals(oldIgnoreExternals); resetLog(); } }
wcAccess.close(); SVNStatusClient statusClient = new SVNStatusClient((ISVNAuthenticationManager) null, getOptions()); statusClient.setIgnoreExternals(true); final long[] maxRevision = new long[1]; final long[] minRevision = new long[]{-1}; final boolean[] switched = new boolean[3]; final String[] wcURL = new String[1]; statusClient.doStatus(path, SVNRevision.WORKING, SVNDepth.INFINITY, false, true, false, false, new ISVNStatusHandler() { public void handleStatus(SVNStatus status) { if (status.getEntryProperties() == null || status.getEntryProperties().isEmpty()) {
String[] validatedPaths = new String[paths.length]; for (int i = 0; i < paths.length; i++) { statusClient.checkCancelled(); File file = paths[i]; validatedPaths[i] = file.getAbsolutePath().replace(File.separatorChar, '/'); Collection dirsToLockRecursively = new SVNHashSet(); if (relativePaths.isEmpty()) { statusClient.checkCancelled(); String target = SVNWCManager.getActualTarget(baseDir); if (!"".equals(target)) { statusClient.checkCancelled(); String targetPath = (String) targets.next(); File targetFile = new File(baseDir, targetPath); baseAccess.setOptions(statusClient.getOptions()); try { baseAccess.open(baseDir, true, lockAll ? SVNWCAccess.INFINITE_DEPTH : 0); statusClient.checkCancelled(); dirsToLock = new ArrayList(dirsToLock); dirsToLockRecursively = new ArrayList(dirsToLockRecursively); removeRedundantPaths(dirsToLockRecursively, dirsToLock); for (Iterator nonRecusivePaths = dirsToLock.iterator(); nonRecusivePaths.hasNext();) { statusClient.checkCancelled(); String path = (String) nonRecusivePaths.next(); File pathFile = new File(baseDir, path);