Refine search
private DirEntry getDirEntry(SVNDirEntry dirEntry) { if (dirEntry == null) { return null; } String repositoryRootString = getUrlString(dirEntry.getRepositoryRoot()); String urlString = getUrlString(dirEntry.getURL()); String absolutePath = SVNPathUtil.getRelativePath(repositoryRootString, urlString); return new DirEntry(dirEntry.getRelativePath(), absolutePath, getNodeKind(dirEntry.getKind()), dirEntry.getSize(), dirEntry.hasProperties(), dirEntry.getRevision(), getLongDate(dirEntry.getDate()), dirEntry.getAuthor()); }
public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException { if (entries != null) { dirEntry = new SVNDirEntry(url.appendPath(dirEntry.getName(), false), repositoryRoot, dirEntry.getName(), dirEntry.getKind(), dirEntry.getSize(), dirEntry.hasProperties(), dirEntry.getRevision(), dirEntry.getDate(), dirEntry.getAuthor()); entries.add(dirEntry); } } };
static SVNInfo createInfo(String path, SVNURL reposRootURL, String uuid, SVNURL url, SVNRevision revision, SVNDirEntry dirEntry, SVNLock lock) { if (dirEntry == null) { return null; } return new SVNInfo(path, url, revision, dirEntry.getKind(), uuid, reposRootURL, dirEntry.getRevision(), dirEntry.getDate(), dirEntry.getAuthor(), lock, SVNDepth.UNKNOWN, dirEntry.getSize()); }
protected void printDirEntry(SVNDirEntry dirEntry) { String path = dirEntry.getRelativePath(); if ("".equals(path)) { if (getSVNEnvironment().isVerbose() && dirEntry.getKind() == SVNNodeKind.DIR) { path = "."; } else if (dirEntry.getKind() == SVNNodeKind.DIR) { return; if (dirEntry.getExternalParentUrl() != null && dirEntry.getExternalTarget() != null) { if ((lastExternalParentUrl == null && lastExternalTarget == null) || (!lastExternalParentUrl.equals(dirEntry.getExternalParentUrl()) || !lastExternalTarget.equals(dirEntry.getExternalTarget()))) { buffer.append("Listing external '").append(dirEntry.getExternalTarget()).append("' defined on '").append(dirEntry.getExternalParentUrl()).append("':\n"); lastExternalParentUrl = dirEntry.getExternalParentUrl(); lastExternalTarget = dirEntry.getExternalTarget(); buffer.append(SVNFormatUtil.formatString(dirEntry.getRevision() + "", 7, false)); buffer.append(' '); String author = dirEntry.getAuthor() == null ? " ? " : dirEntry.getAuthor(); if (author.length() > 8) { author = author.substring(0, 8); buffer.append(dirEntry.getLock() != null ? 'O' : ' '); buffer.append(' '); buffer.append(SVNFormatUtil.formatString(dirEntry.getKind() == SVNNodeKind.DIR ? "" : dirEntry.getSize() + "", 10, false)); buffer.append(' '); Date d = dirEntry.getDate(); String timeStr = ""; if (d != null) {
private void collectInfo(SVNRepository repos, SVNDirEntry entry, SVNRevision rev, String path, SVNURL root, String uuid, SVNURL url, Map locks, boolean recursive, ISVNInfoHandler handler) throws SVNException { checkCancelled(); String displayPath = repos.getFullPath(path); displayPath = displayPath.substring(repos.getLocation().getPath().length()); if ("".equals(displayPath) || "/".equals(displayPath)) { displayPath = path; } handler.handleInfo(SVNInfo.createInfo(displayPath, root, uuid, url, rev, entry, (SVNLock) locks.get(path))); if (entry.getKind() == SVNNodeKind.DIR && recursive) { Collection children = repos.getDir(path, rev.getNumber(), null, new ArrayList()); for (Iterator ents = children.iterator(); ents.hasNext();) { SVNDirEntry child = (SVNDirEntry) ents.next(); SVNURL childURL = url.appendPath(child.getName(), false); collectInfo(repos, child, rev, SVNPathUtil.append(path, child.getName()), root, uuid, childURL, locks, recursive, handler); } } }
private void sendToHandler(SVNDirEntry entry) throws SAXException { if ("".equals(entry.getRelativePath())) { if (entry.getKind() == SVNNodeKind.DIR) { return; addTag(NAME_TAG, entry.getRelativePath()); if (entry.getKind() == SVNNodeKind.FILE) { addTag(SIZE_TAG, entry.getSize() + ""); addAttribute(REVISION_ATTR, entry.getRevision() + ""); openTag(COMMIT_TAG); addTag(AUTHOR_TAG, entry.getAuthor()); addTag(DATE_TAG, SVNDate.formatDate(entry.getDate())); closeTag(COMMIT_TAG); SVNLock lock = entry.getLock(); if (lock != null) { openTag(LOCK_TAG);
SVNLock[] locks = new SVNLock[0]; try { locks = repos.getLocks(""); } catch (SVNException e) { if (!(e.getErrorMessage() != null && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_IMPLEMENTED)) { SVNURL root = repos.getRepositoryRoot(true); for (int i = 0; i < locks.length; i++) { String repositoryPath = locks[i].getPath(); locksMap.put(root.appendPath(repositoryPath, false), locks[i]); if (repos.checkPath("", rev) == SVNNodeKind.FILE) { String name = SVNPathUtil.tail(repos.getLocation().getPath()); SVNURL fileULR = repos.getLocation(); repos.setLocation(repos.getLocation().removePathTail(), false); Collection dirEntries = repos.getDir("", rev, null, (Collection) null); for (Iterator ents = dirEntries.iterator(); ents.hasNext();) { SVNDirEntry dirEntry = (SVNDirEntry) ents.next(); if (name.equals(dirEntry.getName())) { fileEntry = dirEntry; break; fileEntry.setRelativePath(name); nestedHandler.handleDirEntry(fileEntry); } else {
private void diffDeletedDir(String path) throws SVNException { Collection<SVNDirEntry> entries = myRepository.getDir(path, myRevision, null, SVNDirEntry.DIRENT_KIND, (Collection<SVNDirEntry>) null); for (SVNDirEntry entry : entries) { String name = entry.getName(); if ("".equals(name)) { continue; } String entryPath = SVNPathUtil.append(path, name); String statusPath = getStatusPath(entryPath); SVNDiffStatus status = new SVNDiffStatus( myAnchor != null ? new File(myAnchor, entryPath) : null, myRootURL.appendPath(entryPath, false), statusPath, SVNStatusType.STATUS_DELETED, false, entry.getKind()); myHandler.handleDiffStatus(status); if (entry.getKind() == SVNNodeKind.DIR) { diffDeletedDir(entryPath); } } }
public Map<String, String> listEntries(String _path, String _asof, String _until) { Map<String, String> l = new HashMap<String, String>(); //String rel_path = url.toString().replace(rootRepo.getDir("", -1, null, (Collection<SVNDirEntry>)null).iterator().next(), ""); try { Collection<SVNDirEntry> entries = this.rootRepo.getDir(_path, -1, null,(Collection<SVNDirEntry>) null); //this.getDirEntries(path); Iterator<SVNDirEntry> iterator = entries.iterator(); String name = null, path = null; long rev = -1; // Use an iterator to get all directory entries in a certain path ("tags/") int asof = (_asof==null?-1:Integer.parseInt(_asof)); int until = (_until==null?-1:Integer.parseInt(_until)); while (iterator.hasNext()) { SVNDirEntry entry = (SVNDirEntry) iterator.next(); SvnClient.log.debug( "Path mess: " + entry.getPath() + " | " + entry.getRelativePath() + " | " + entry.getRepositoryRoot() + " | " + entry.getExternalParentUrl() + " | " + entry.getURL()); name = entry.getName(); rev = entry.getRevision(); path = entry.getURL().toString().substring(entry.getRepositoryRoot().toString().length()); if( asof<rev && (_until==null || rev<until) ) l.put(path, Long.toString(rev)); } } catch (Exception e) { SvnClient.log.error( "Error while getting directory entries: " + e.getMessage() ); } // return the tag name and the corresponding revision number return l; }
public static DirEntry createDirEntry(SVNDirEntry dirEntry) { if(dirEntry == null){ return null; } return new DirEntry( dirEntry.getRelativePath(), getNodeKind(dirEntry.getKind()), dirEntry.getSize(), dirEntry.hasProperties(), dirEntry.getRevision(), dirEntry.getDate() != null ? dirEntry.getDate().getTime()*1000 : 0, dirEntry.getAuthor() ); }
try { properties = externals == null ? null : new SVNProperties(); entries = repository.getDir(path, rev, properties, entryFields, entries); } catch (SVNAuthenticationException e) { return; SVNURL location = repository.getLocation(); externals.put(location.appendPath(path, false), svnExternalsVaule); String childPath = SVNPathUtil.append(path, entry.getName()); entry.setRelativePath(childPath); if (entry.getKind() == SVNNodeKind.FILE || depth == SVNDepth.IMMEDIATES || depth == SVNDepth.INFINITY) { entry.setExternalParentUrl(externalParentUrl); entry.setExternalTarget(externalTarget); handler.handleDirEntry(entry); if (entry.getKind() == SVNNodeKind.DIR && entry.getDate() != null && depth == SVNDepth.INFINITY) { list(repository, childPath, rev, depth, entryFields, externals, externalParentUrl, externalTarget, handler);
public void process( @NotNull CmdLine cmdLine ) throws IOException, SVNException { cmdLine.out( SubversionMessageHandler.get( "module.list.repository.entries" ) ); String repositoryUrl = cmdLine.read( SubversionMessageHandler.get( "wich.repository.shall.be.used" ), subversionSupport.getRepositoryUrls(), null ); subversionSupport.addRepositoryUrl( repositoryUrl ); cmdLine.warning( SubversionMessageHandler.get( "listing.repository.entries" ) ); cmdLine.out( SubversionMessageHandler.get( "repository" ) ); cmdLine.success( '\t' + repositoryUrl ); SVNURL svnurl = SVNURL.parseURIDecoded( repositoryUrl ); SVNRepository repository = SVNRepositoryFactory.create( svnurl ); repository.setAuthenticationManager( subversionSupport.getAuthenticationManager() ); Collection<SVNDirEntry> dirEntry = repository.getDir( ".", repository.getLatestRevision(), null, ( Collection<?> ) null ); for ( SVNDirEntry entry : dirEntry ) { cmdLine.out( entry.getRelativePath() + "\t\t(" + entry.getKind() + ")" ); } } }
public SCMRepository info() { SVNRepository repository = null; try { SVNURL url = SVNURL.parseURIEncoded(path); repository = SVNRepositoryFactory.create(url); authenticateIfNecessary(repository); SVNDirEntry firstRevision = repository.info("/", 0); SVNDirEntry lastRevision = repository.info("/", SVNRevision.HEAD.getNumber()); return new SCMRepository(this, lastRevision.getURL().getPath(), path, String.valueOf(lastRevision.getRevision()), String.valueOf(firstRevision .getRevision())); } catch (SVNException e) { throw new RuntimeException("error in getHead() for " + path, e); } finally { if (repository != null) repository.closeSession(); } }
/** * {@inheritDoc} */ @Override public void testRepository(ScmCriteria criteria) throws Exception { SVNRepository repository = null; try { repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(criteria.getServer())); if (criteria.isAuth()) { repository.setAuthenticationManager(FactoryAuthenticationManager.create(criteria)); } long revision = -1; SVNDirEntry dir = repository.info(".", revision); if (dir == null) { throw new Exception("Error reading the repository information."); } revision = dir.getRevision(); LOGGER.log(Level.INFO, "Revision {0} is the last in the repository {1}", new Object[]{revision, criteria.getServer()}); } finally { if (repository != null) { repository.closeSession(); } } } }
private List<String> dirCheckout(SvnOperationFactory svnOperationFactory) throws SVNException { SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIEncoded(URL),null); repository.setAuthenticationManager(svnOperationFactory.getAuthenticationManager()); Collection<SVNDirEntry> entries = (Collection<SVNDirEntry>) repository.getDir("", (Your Object).getRevision(), null,(Collection<?>) null); Iterator<SVNDirEntry> iterator =entries.iterator(); List<String> list = new ArrayList<String>(); while(iterator.hasNext()){ SVNDirEntry entry =(SVNDirEntry) iterator.next(); if(entry.getKind()==SVNNodeKind.DIR) list.add(entry.getName()); } return list; }
@Override public ChangeSet getHead() { SVNRepository repository = null; try { SVNURL url = SVNURL.parseURIEncoded(path); repository = SVNRepositoryFactory.create(url); authenticateIfNecessary(repository); SVNDirEntry entry = repository.info("/", -1); return new ChangeSet(String.valueOf(entry.getRevision()), convertToCalendar(entry.getDate())); } catch (SVNException e) { throw new RuntimeException("error in getHead() for " + path, e); } finally { if (repository != null) repository.closeSession(); } }
/** * Compares this object with another one. * * @param o an object to compare with * @return <ul> * <li>-1 - if <code>o</code> is either <span class="javakeyword">null</span>, * or is not an instance of <b>SVNDirEntry</b>, or this entry's URL is lexicographically * less than the name of <code>o</code>; * </li> * <li>1 - if this entry's URL is lexicographically greater than the name of <code>o</code>; * </li> * <li>0 - if and only if <code>o</code> has got the same URL as this one has * </li> * </ul> */ public int compareTo(Object o) { if (o == null || o.getClass() != SVNDirEntry.class) { return -1; } SVNNodeKind otherKind = ((SVNDirEntry) o).getKind(); if (otherKind != getKind()) { return getKind().compareTo(otherKind); } String otherURL = ((SVNDirEntry) o).getURL().toString(); return myURL.toString().compareTo(otherURL); } }
private static void list(SVNRepository repository, String path, long rev, boolean recursive, ISVNDirEntryHandler handler) throws SVNException { Collection entries = new TreeSet(); entries = repository.getDir(path, rev, null, entries); for (Iterator iterator = entries.iterator(); iterator.hasNext();) { SVNDirEntry entry = (SVNDirEntry) iterator.next(); String childPath = SVNPathUtil.append(path, entry.getName()); entry.setRelativePath(childPath); handler.handleDirEntry(entry); if (entry.getKind() == SVNNodeKind.DIR && entry.getDate() != null && recursive) { list(repository, childPath, rev, recursive, handler); } } }
public void handleDirEntry(SVNDirEntry entry) throws SVNException { children.add( new ChildEntry(entry.getRevision(), entry.getDate().getTime(), entry.getKind(), entry.getName())); }