org.tmatesoft.svn.core.SVNNodeKind Java Examples
The following examples show how to use
org.tmatesoft.svn.core.SVNNodeKind.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubversionCommit.java From Getaviz with Apache License 2.0 | 6 votes |
private Map<String, VersionedFile> getFiles(String path, Iterable<Pattern> filters) throws FilesNotAvailableException { IterablePatternMatcher matcher = new IterablePatternMatcher(); try { Map<String, VersionedFile> returnable = new HashMap<String, VersionedFile>(); List<SVNDirEntry> entries = new ArrayList<SVNDirEntry>(); repo.getDir(path, entry.getRevision(), false, entries); for (SVNDirEntry dirEntry : entries) { SVNNodeKind kind = dirEntry.getKind(); String currentFilePath = path + dirEntry.getName(); if (SVNNodeKind.FILE.equals(kind)) { if (matcher.isIncluded(filters, currentFilePath)) { returnable.put(currentFilePath, new LazySvnVersionedFile(repo, currentFilePath, this.entry.getRevision())); } } else if (SVNNodeKind.DIR.equals(kind)) { returnable.putAll(getFiles(currentFilePath + "/", filters)); } else { System.err.println("skipping unknown versioned item " + currentFilePath); } } return returnable; } catch (SVNException e) { throw new FilesNotAvailableException(e); } }
Example #2
Source File: SubversionRepository.java From Getaviz with Apache License 2.0 | 5 votes |
private void addToMap(List<SVNDirEntry> currentEntries, Map<String, String> pathMap, String basePath) { for(SVNDirEntry entry : currentEntries){ if(SVNNodeKind.DIR.equals(entry.getKind())){ String entryName = entry.getName(); pathMap.put(entryName, basePath + entryName); } } }
Example #3
Source File: SvnUtil.java From scava with Eclipse Public License 2.0 | 5 votes |
public static void verifySVNLocation(SVNRepository repository, String url) throws SVNException{ SVNNodeKind nodeKind = repository.checkPath("", -1); if (nodeKind == SVNNodeKind.NONE) { System.err.println("There is no entry at '" + url + "'."); System.exit(1); } else if (nodeKind == SVNNodeKind.FILE) { System.err.println("The entry at '" + url + "' is a file while a directory was expected."); System.exit(1); } }
Example #4
Source File: SvnUtil.java From scava with Eclipse Public License 2.0 | 5 votes |
public static void listEntries(SVNRepository repository, String path) throws SVNException { Collection<?> entries = repository.getDir(path, -1, null, (Collection<?>) null); Iterator<?> iterator = entries.iterator(); while (iterator.hasNext()) { SVNDirEntry entry = (SVNDirEntry) iterator.next(); System.out.println("/" + (path.equals("") ? "" : path + "/") + entry.getName() + " (author: '" + entry.getAuthor() + "'; revision: " + entry.getRevision() + "; date: " + entry.getDate() + ")"); if (entry.getKind() == SVNNodeKind.DIR) { listEntries(repository, (path.equals("")) ? entry.getName(): path + "/" + entry.getName()); } } }
Example #5
Source File: SvnUtil.java From scava with Eclipse Public License 2.0 | 5 votes |
public static List<SVNDirEntry> getEntries(SVNRepository repository, String path) throws SVNException { Collection<?> entries = repository.getDir(path, -1, null, (Collection<?>) null); List<SVNDirEntry> entryURLs= new ArrayList<SVNDirEntry>(); Iterator<?> iterator = entries.iterator(); while (iterator.hasNext()) { SVNDirEntry entry = (SVNDirEntry) iterator.next(); entryURLs.add(entry); if (entry.getKind() == SVNNodeKind.DIR) { entryURLs.addAll(getEntries(repository, (path.equals("")) ? entry.getName(): path + "/" + entry.getName()) ); } } return entryURLs; }
Example #6
Source File: SvnProctor.java From proctor with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<Revision> getHistory(final String test, final String version, final int start, final int limit) throws StoreException { final Long revision = SvnPersisterCoreImpl.parseRevisionOrDie(version); return getSvnCore().doWithClientAndRepository(new SvnPersisterCore.SvnOperation<List<Revision>>() { @Override public List<Revision> execute(final SVNRepository repo, final SVNClientManager clientManager) throws Exception { // check path before executing svn log final String testPath = getTestDefinitionsDirectory() + "/" + test; final SVNNodeKind kind = repo.checkPath(testPath, revision); if (kind == SVNNodeKind.NONE) { return Collections.emptyList(); } final String[] targetPaths = {testPath}; final SVNRevision svnRevision = SVNRevision.create(revision); return getSVNLogs(clientManager, targetPaths, svnRevision, start, limit); } @Override public StoreException handleException(final Exception e) throws StoreException { throw new StoreException.ReadException("Unable to get older revisions for " + test + " r" + revision, e); } }); }
Example #7
Source File: GitLogEntry.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
public @NotNull SVNNodeKind getKind() { if (newEntry != null) return newEntry.getKind(); if (oldEntry != null) return oldEntry.getKind(); throw new IllegalStateException(); }
Example #8
Source File: CheckPathAndStatCmdTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void existentFile(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester tester = create(factory)) { final SVNRepository repository = tester.openSvnRepository(); assertPath(repository, "/existent", repository.getLatestRevision(), SVNNodeKind.FILE); } }
Example #9
Source File: GitFile.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@NotNull default SVNNodeKind getKind() { final int objType = getFileMode().getObjectType(); switch (objType) { case Constants.OBJ_TREE: case Constants.OBJ_COMMIT: return SVNNodeKind.DIR; case Constants.OBJ_BLOB: return SVNNodeKind.FILE; default: throw new IllegalStateException("Unknown obj type: " + objType); } }
Example #10
Source File: CheckPathCmd.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Override protected void processCommand(@NotNull SessionContext context, @NotNull Params args) throws IOException, SVNException { final int revision = getRevisionOrLatest(args.rev, context); final GitFile file = context.getFile(revision, args.path); final SVNNodeKind kind = file == null ? SVNNodeKind.NONE : file.getKind(); final SvnServerWriter writer = context.getWriter(); writer .listBegin() .word("success") .listBegin() .word(kind.toString()) // kind .listEnd() .listEnd(); }
Example #11
Source File: CheckPathAndStatCmdTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void nonexistentFileInInitialRev(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester tester = create(factory)) { final SVNRepository repository = tester.openSvnRepository(); assertPath(repository, "/existent", 0, SVNNodeKind.NONE); } }
Example #12
Source File: CheckPathAndStatCmdTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
private static void assertPath(@NotNull SVNRepository repository, @NotNull String path, long rev, @NotNull SVNNodeKind expectedKind) throws SVNException { final SVNNodeKind nodeKind = repository.checkPath(path, rev); Assert.assertEquals(nodeKind, expectedKind); final SVNDirEntry info = repository.info(path, rev); if (expectedKind == SVNNodeKind.NONE) { Assert.assertNull(info); } else { Assert.assertEquals(info.getKind(), expectedKind); Assert.assertEquals(info.getRevision(), rev); } }
Example #13
Source File: CheckPathAndStatCmdTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void nonexistentFile(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester tester = create(factory)) { final SVNRepository repository = tester.openSvnRepository(); assertPath(repository, "/nonexistent", repository.getLatestRevision(), SVNNodeKind.NONE); } }
Example #14
Source File: CheckPathAndStatCmdTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@Test(dataProvider = "all", dataProviderClass = SvnTesterDataProvider.class) public void root(@NotNull SvnTesterFactory factory) throws Exception { try (SvnTester tester = create(factory)) { final SVNRepository repository = tester.openSvnRepository(); assertPath(repository, "", repository.getLatestRevision(), SVNNodeKind.DIR); } }
Example #15
Source File: SvnPersisterCoreImpl.java From proctor with Apache License 2.0 | 4 votes |
@Override public TestVersionResult determineVersions(final String fetchRevision) throws StoreException.ReadException { checkShutdownState(); return doReadWithClientAndRepository(new SvnOperation<TestVersionResult>() { @Override public TestVersionResult execute(final SVNRepository repo, final SVNClientManager clientManager) throws Exception { final String testDefPath = testDefinitionsDirectory; /* final SVNDirEntry info = repo.info(testDefPath, 2); if (info == null) { LOGGER.warn("No test matrix found in " + testDefPath + " under " + svnPath); return null; } */ final Long revision = fetchRevision.length() > 0 ? parseRevisionOrDie(fetchRevision) : Long.valueOf(-1); final SVNRevision svnRevision = revision.longValue() > 0 ? SVNRevision.create(revision.longValue()) : SVNRevision.HEAD; final SVNLogClient logClient = clientManager.getLogClient(); final FilterableSVNDirEntryHandler handler = new FilterableSVNDirEntryHandler(); final SVNURL url = SvnPersisterCoreImpl.this.svnUrl.appendPath(testDefPath, false); logClient.doList(url, svnRevision, svnRevision, /* fetchlocks */false, SVNDepth.IMMEDIATES, SVNDirEntry.DIRENT_KIND | SVNDirEntry.DIRENT_CREATED_REVISION, handler); final SVNDirEntry logEntry = handler.getParent(); final List<TestVersionResult.Test> tests = Lists.newArrayListWithExpectedSize(handler.getChildren().size()); for (final SVNDirEntry testDefFile : handler.getChildren()) { if (testDefFile.getKind() != SVNNodeKind.DIR) { LOGGER.warn(String.format("svn kind (%s) is not SVNNodeKind.DIR, skipping %s", testDefFile.getKind(), testDefFile.getURL())); continue; } final String testName = testDefFile.getName(); final long testRevision; /* When a svn directory gets copied using svn cp source-dir destination-dir, the revision returned by svn list --verbose directory is different from that of svn log directory/sub-dir The revision returned by svn list is the revision of the on the source-dir instead of the destination-dir The code below checks to see if the directory at the provided revision exists, if it does it will use this revision. If the directory does does not exist, try and identify the correct revision using svn log. */ final SVNLogEntry log = getMostRecentLogEntry(clientManager, testDefPath + "/" + testDefFile.getRelativePath(), svnRevision); if (log != null && log.getRevision() != testDefFile.getRevision()) { // The difference in the log.revision and the list.revision can occur during an ( svn cp ) if (LOGGER.isDebugEnabled()) { LOGGER.debug("svn log r" + log.getRevision() + " is different than svn list r" + testDefFile.getRevision() + " for " + testDefFile.getURL()); } testRevision = log.getRevision(); } else { testRevision = testDefFile.getRevision(); } tests.add(new TestVersionResult.Test(testName, String.valueOf(testRevision))); } final String matrixRevision = String.valueOf(logEntry.getRevision()); return new TestVersionResult( tests, logEntry.getDate(), logEntry.getAuthor(), matrixRevision, logEntry.getCommitMessage() ); } @Override public StoreException handleException(final Exception e) throws StoreException { throw new StoreException.ReadException("Unable to read from SVN", e); } }); }
Example #16
Source File: GitFile.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
default boolean isDirectory() { return getKind().equals(SVNNodeKind.DIR); }
Example #17
Source File: MCRVersionedMetadata.java From mycore with GNU General Public License v3.0 | 4 votes |
void commit(String mode) throws IOException { // Commit to SVN SVNCommitInfo info; try { SVNRepository repository = getStore().getRepository(); // Check which paths already exist in SVN String[] paths = store.getSlotPaths(id); int existing = paths.length - 1; for (; existing >= 0; existing--) { if (!repository.checkPath(paths[existing], -1).equals(SVNNodeKind.NONE)) { break; } } existing += 1; // Start commit editor String commitMsg = mode + "d metadata object " + store.getID() + "_" + id + " in store"; ISVNEditor editor = repository.getCommitEditor(commitMsg, null); editor.openRoot(-1); // Create directories in SVN that do not exist yet for (int i = existing; i < paths.length - 1; i++) { LOGGER.debug("SVN create directory {}", paths[i]); editor.addDir(paths[i], null, -1); editor.closeDir(); } // Commit file changes String filePath = paths[paths.length - 1]; if (existing < paths.length) { editor.addFile(filePath, null, -1); } else { editor.openFile(filePath, -1); } editor.applyTextDelta(filePath, null); SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator(); String checksum; try (InputStream in = Files.newInputStream(path)) { checksum = deltaGenerator.sendDelta(filePath, in, editor, true); } if (store.shouldForceXML()) { editor.changeFileProperty(filePath, SVNProperty.MIME_TYPE, SVNPropertyValue.create("text/xml")); } editor.closeFile(filePath, checksum); editor.closeDir(); // root info = editor.closeEdit(); } catch (SVNException e) { throw new IOException(e); } revision = () -> Optional.of(info.getNewRevision()); LOGGER.info("SVN commit of {} finished, new revision {}", mode, getRevision()); if (MCRVersioningMetadataStore.shouldSyncLastModifiedOnSVNCommit()) { setLastModified(info.getDate()); } }
Example #18
Source File: SubversionOperation.java From Getaviz with Apache License 2.0 | 4 votes |
public void setFileType(SVNNodeKind svnFileType) { this.fileType = svnFileTypesMapping.get(svnFileType); }