Java Code Examples for org.tmatesoft.svn.core.io.SVNRepository#log()
The following examples show how to use
org.tmatesoft.svn.core.io.SVNRepository#log() .
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: MCRVersionedMetadata.java From mycore with GNU General Public License v3.0 | 6 votes |
private long getLastRevision(boolean deleted) throws SVNException { SVNRepository repository = getStore().getRepository(); if (repository.getLatestRevision() == 0) { //new repository cannot hold a revision yet (MCR-1196) return -1; } final String path = getFilePath(); String dir = getDirectory(); LastRevisionLogHandler lastRevisionLogHandler = new LastRevisionLogHandler(path, deleted); int limit = 0; //we stop through LastRevisionFoundException try { repository.log(new String[] { dir }, repository.getLatestRevision(), 0, true, true, limit, false, null, lastRevisionLogHandler); } catch (LastRevisionFoundException ignored) { } return lastRevisionLogHandler.getLastRevision(); }
Example 2
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 6 votes |
/** * Check commit .gitattributes. */ @Test public void commitUpdatePropertiesRoot() throws Exception { //Map<String, String> props = new HashMap<>()["key":""]; try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); createFile(repo, "/sample.txt", "", propsEolNative); checkFileProp(repo, "/sample.txt", propsEolNative); createFile(repo, "/.gitattributes", "*.txt\t\t\ttext eol=lf\n", propsEolNative); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. checkFileProp(repo, "/sample.txt", propsEolLf); // After commit .gitattributes directory with .gitattributes must change property svn:auto-props automagically. checkDirProp(repo, "/", propsAutoProps); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. { final Set<String> changed = new HashSet<>(); repo.log(new String[]{""}, repo.getLatestRevision(), repo.getLatestRevision(), true, false, logEntry -> changed.addAll(logEntry.getChangedPaths().keySet())); Assert.assertTrue(changed.contains("/")); Assert.assertTrue(changed.contains("/.gitattributes")); Assert.assertTrue(changed.contains("/sample.txt")); Assert.assertEquals(changed.size(), 3); } } }
Example 3
Source File: SvnManager.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * TODO: Cache the log? */ @Override public String getFirstRevision(VcsRepository repository) throws Exception { SVNRepository svnRepository = getSVNRepository((SvnRepository) repository); Collection<?> c = svnRepository.log(new String[]{""}, null, 0, Long.valueOf(getCurrentRevision(repository)), true, true); for (Object o : c) { return String.valueOf(((SVNLogEntry) o).getRevision()); } return null; }
Example 4
Source File: MCRVersionedMetadata.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * Lists all versions of this metadata object available in the subversion * repository * * @return all stored versions of this metadata object */ @SuppressWarnings("unchecked") public List<MCRMetadataVersion> listVersions() throws IOException { try { List<MCRMetadataVersion> versions = new ArrayList<>(); SVNRepository repository = getStore().getRepository(); String path = getFilePath(); String dir = getDirectory(); Collection<SVNLogEntry> entries = null; try { entries = repository.log(new String[] { dir }, null, 0, repository.getLatestRevision(), true, true); } catch (Exception ioex) { LOGGER.error("Could not get versions", ioex); return versions; } for (SVNLogEntry entry : entries) { SVNLogEntryPath svnLogEntryPath = entry.getChangedPaths().get(path); if (svnLogEntryPath != null) { char type = svnLogEntryPath.getType(); versions.add(new MCRMetadataVersion(this, entry, type)); } } return versions; } catch (SVNException svnExc) { throw new IOException(svnExc); } }
Example 5
Source File: MCRVersionedMetadata.java From mycore with GNU General Public License v3.0 | 5 votes |
public MCRMetadataVersion getRevision(long revision) throws IOException { try { if (revision < 0) { revision = getLastPresentRevision(); if (revision < 0) { LOGGER.warn("Metadata object {} in store {} has no last revision!", getID(), getStore().getID()); return null; } } SVNRepository repository = getStore().getRepository(); String path = getFilePath(); String dir = getDirectory(); @SuppressWarnings("unchecked") Collection<SVNLogEntry> log = repository.log(new String[] { dir }, null, revision, revision, true, true); for (SVNLogEntry logEntry : log) { SVNLogEntryPath svnLogEntryPath = logEntry.getChangedPaths().get(path); if (svnLogEntryPath != null) { char type = svnLogEntryPath.getType(); return new MCRMetadataVersion(this, logEntry, type); } } LOGGER.warn("Metadata object {} in store {} has no revision ''{}''!", getID(), getStore().getID(), getRevision()); return null; } catch (SVNException svnExc) { throw new IOException(svnExc); } }
Example 6
Source File: ReplayTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
private void checkCopyFrom(@NotNull SVNRepository repo, @NotNull CopyFromSVNEditor editor, long revision) throws SVNException { final Map<String, String> copyFrom = new TreeMap<>(); repo.log(new String[]{""}, revision, revision, true, true, logEntry -> { for (SVNLogEntryPath entry : logEntry.getChangedPaths().values()) { if (entry.getCopyPath() != null) { copyFrom.put(entry.getPath(), entry.getCopyPath() + "@" + entry.getCopyRevision()); } } }); Assert.assertEquals(editor.getCopyFrom(), copyFrom); }
Example 7
Source File: SvnCheckoutTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
@NotNull private List<Long> loadUpdateRevisions(@NotNull SVNRepository repo, @NotNull String path) throws SVNException { final long maxRevision = Math.min(100, repo.getLatestRevision()); final LinkedList<Long> revisions = new LinkedList<>(); repo.log(new String[]{path}, maxRevision, 0, false, false, logEntry -> revisions.addFirst(logEntry.getRevision())); return new ArrayList<>(revisions); }
Example 8
Source File: SvnManager.java From scava with Eclipse Public License 2.0 | 4 votes |
@Override public VcsRepositoryDelta getDelta(VcsRepository repository, String startRevision, String endRevision) throws Exception { SvnRepository _svnRepository = (SvnRepository) repository; SVNRepository svnRepository = getSVNRepository(_svnRepository); VcsRepositoryDelta delta = new VcsRepositoryDelta(); delta.setRepository(repository); String userProviderURL = _svnRepository.getUrl(); String rootURL = svnRepository.getRepositoryRoot(false).toDecodedString(); String overLappedURL = makeRelative(rootURL, userProviderURL); if (!overLappedURL.startsWith("/")) { overLappedURL = "/" + overLappedURL; } // if (!startRevision.equals(endRevision)) { Collection<?> c = svnRepository.log(new String[]{""}, null, Long.valueOf(startRevision), Long.valueOf(endRevision), true, true); for (Object o : c) { SVNLogEntry svnLogEntry = (SVNLogEntry) o; VcsCommit commit = new VcsCommit(); commit.setAuthor(svnLogEntry.getAuthor()); commit.setAuthorEmail(svnLogEntry.getAuthor()); commit.setMessage(svnLogEntry.getMessage()); commit.setRevision(svnLogEntry.getRevision() + ""); commit.setDelta(delta); commit.setJavaDate(svnLogEntry.getDate()); delta.getCommits().add(commit); Map<String, SVNLogEntryPath> changedPaths = svnLogEntry.getChangedPaths(); for (String path : changedPaths.keySet()) { SVNLogEntryPath svnLogEntryPath = changedPaths.get(path); // String[] exts = {".cxx",".h",".hxx",".cpp",".cpp",".html"}; // System.err.println(path); // if (svnLogEntryPath.getKind() == SVNNodeKind.FILE) { String[] blacklist = {".png",".jpg",".bmp",".zip",".jar",".gz",".tar"}; if (path.lastIndexOf(".") <= 0) continue; String ext = path.substring(path.lastIndexOf("."), path.length()); // System.err.println(ext + " in " + blacklist + " == " + !Arrays.asList(blacklist).contains(ext)); if (!Arrays.asList(blacklist).contains(ext)){ VcsCommitItem commitItem = new VcsCommitItem(); commit.getItems().add(commitItem); commitItem.setCommit(commit); String relativePath = makeRelative(overLappedURL, path); if (!relativePath.startsWith("/")) { relativePath = "/" + relativePath; } commitItem.setPath(relativePath); if (svnLogEntryPath.getType() == 'A') { commitItem.setChangeType(VcsChangeType.ADDED); } else if (svnLogEntryPath.getType() == 'M') { commitItem.setChangeType(VcsChangeType.UPDATED); } else if (svnLogEntryPath.getType() == 'D') { commitItem.setChangeType(VcsChangeType.DELETED); } else if (svnLogEntryPath.getType() == 'R') { commitItem.setChangeType(VcsChangeType.REPLACED); } else { System.err.println("Found unrecognised svn log entry type: " + svnLogEntryPath.getType()); commitItem.setChangeType(VcsChangeType.UNKNOWN); } } // } } } // } return delta; }
Example 9
Source File: SvnLogTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
private void checkLogLimit(@NotNull SVNRepository repo, long r1, long r2, int limit, @NotNull String path, @NotNull LogEntry... expecteds) throws SVNException { final List<LogEntry> actual = new ArrayList<>(); repo.log(new String[]{path}, r1, r2, true, false, limit, logEntry -> actual.add(new LogEntry(logEntry))); ArrayAsserts.assertArrayEquals(expecteds, actual.toArray(new LogEntry[0])); }
Example 10
Source File: SvnFilePropertyTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
/** * Check commit .gitattributes. */ @Test public void commitUpdatePropertiesSubdir() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); { final ISVNEditor editor = repo.getCommitEditor("Create directory: /foo", null, false, null); editor.openRoot(-1); editor.addDir("/foo", null, -1); // Empty file. final String emptyFile = "/foo/.keep"; editor.addFile(emptyFile, null, -1); editor.changeFileProperty(emptyFile, SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, emptyFile, null, ""); // Close dir editor.closeDir(); editor.closeDir(); editor.closeEdit(); } createFile(repo, "/sample.txt", "", propsEolNative); createFile(repo, "/foo/sample.txt", "", propsEolNative); checkFileProp(repo, "/sample.txt", propsEolNative); checkFileProp(repo, "/foo/sample.txt", propsEolNative); createFile(repo, "/foo/.gitattributes", "*.txt\t\t\ttext eol=lf\n", propsEolNative); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. checkFileProp(repo, "/foo/sample.txt", propsEolLf); checkFileProp(repo, "/sample.txt", propsEolNative); // After commit .gitattributes directory with .gitattributes must change property svn:auto-props automagically. checkDirProp(repo, "/foo", propsAutoProps); // After commit .gitattributes file sample.txt must change property svn:eol-style automagically. { final Set<String> changed = new HashSet<>(); repo.log(new String[]{""}, repo.getLatestRevision(), repo.getLatestRevision(), true, false, logEntry -> changed.addAll(logEntry.getChangedPaths().keySet())); Assert.assertTrue(changed.contains("/foo")); Assert.assertTrue(changed.contains("/foo/.gitattributes")); Assert.assertTrue(changed.contains("/foo/sample.txt")); Assert.assertEquals(changed.size(), 3); } } }