Search in sources :

Example 1 with SVNLogEntryPath

use of org.tmatesoft.svn.core.SVNLogEntryPath in project intellij-community by JetBrains.

the class LogEntry method create.

@Nullable
public static LogEntry create(@Nullable SVNLogEntry entry) {
    LogEntry result = null;
    if (entry != null) {
        LogEntry.Builder builder = new LogEntry.Builder();
        if (entry.getChangedPaths() != null) {
            for (SVNLogEntryPath path : entry.getChangedPaths().values()) {
                builder.addPath(LogEntryPath.create(path));
            }
        }
        result = builder.setRevision(entry.getRevision()).setAuthor(entry.getAuthor()).setDate(entry.getDate()).setMessage(entry.getMessage()).setHasChildren(entry.hasChildren()).build();
    }
    return result;
}
Also used : SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with SVNLogEntryPath

use of org.tmatesoft.svn.core.SVNLogEntryPath in project Gargoyle by callakrsos.

the class FxSVNHistoryDataSupplier method createEntryListView.

//	MenuItem createDiffMenu(){
//
//	}
ListView<SVNLogEntry> createEntryListView(ObservableList<SVNLogEntry> list) {
    ListView<SVNLogEntry> listView = new ListView<SVNLogEntry>(list);
    listView.setCellFactory(new Callback<ListView<SVNLogEntry>, ListCell<SVNLogEntry>>() {

        @Override
        public ListCell<SVNLogEntry> call(ListView<SVNLogEntry> param) {
            ListCell<SVNLogEntry> listCell = new ListCell<SVNLogEntry>() {

                /* (non-Javadoc)
					 * @see javafx.scene.control.Cell#updateItem(java.lang.Object, boolean)
					 */
                @Override
                protected void updateItem(SVNLogEntry item, boolean empty) {
                    super.updateItem(item, empty);
                    if (empty) {
                        setText(null);
                    } else {
                        long revision = item.getRevision();
                        String author = item.getAuthor();
                        String dateString = YYYY_MM_DD_HH_MM_SS_PATTERN.format(item.getDate());
                        String message = item.getMessage();
                        setText(String.format("Resivion :%d author %s date :%s message :%s ", revision, author, dateString, message));
                    }
                }
            };
            return listCell;
        }
    });
    listView.setPrefSize(600, ListView.USE_COMPUTED_SIZE);
    listView.addEventHandler(MouseEvent.MOUSE_CLICKED, ev -> {
        if (ev.getClickCount() == 2 && ev.getButton() == MouseButton.PRIMARY) {
            SVNLogEntry selectedItem = listView.getSelectionModel().getSelectedItem();
            if (selectedItem != null) {
                Map<String, SVNLogEntryPath> changedPaths = selectedItem.getChangedPaths();
                if (ValueUtil.isNotEmpty(changedPaths)) {
                    ObservableList<GargoyleSVNLogEntryPath> collect = createStream(Arrays.asList(selectedItem)).collect(FxCollectors.toObservableList());
                    Node showing = null;
                    if (collect.isEmpty()) {
                        showing = new Label("Empty.");
                        showing.setStyle("-fx-text-fill:black");
                    } else {
                        showing = createHistoryListView(collect);
                    }
                    FxUtil.showPopOver(ev.getPickResult().getIntersectedNode(), showing);
                }
            }
        }
    });
    return listView;
}
Also used : SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ListCell(javafx.scene.control.ListCell) Node(javafx.scene.Node) Label(javafx.scene.control.Label) ListView(javafx.scene.control.ListView) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath)

Example 3 with SVNLogEntryPath

use of org.tmatesoft.svn.core.SVNLogEntryPath in project mycore by MyCoRe-Org.

the class MCRVersionedMetadata method listVersions.

/**
 * 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);
    }
}
Also used : SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) ArrayList(java.util.ArrayList) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) MCRUsageException(org.mycore.common.MCRUsageException) JDOMException(org.jdom2.JDOMException) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath)

Example 4 with SVNLogEntryPath

use of org.tmatesoft.svn.core.SVNLogEntryPath in project mycore by MyCoRe-Org.

the class MCRVersionedMetadata method getRevision.

public MCRMetadataVersion getRevision(long revision) throws IOException {
    try {
        if (revision < 0) {
            revision = getLastPresentRevision();
            if (revision < 0) {
                LOGGER.warn(MessageFormat.format("Metadata object {0} in store {1} 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(MessageFormat.format("Metadata object {0} in store {1} has no revision ''{2}''!", getID(), getStore().getID(), getRevision()));
        return null;
    } catch (SVNException svnExc) {
        throw new IOException(svnExc);
    }
}
Also used : SVNLogEntry(org.tmatesoft.svn.core.SVNLogEntry) SVNRepository(org.tmatesoft.svn.core.io.SVNRepository) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException) SVNLogEntryPath(org.tmatesoft.svn.core.SVNLogEntryPath)

Aggregations

SVNLogEntry (org.tmatesoft.svn.core.SVNLogEntry)4 SVNLogEntryPath (org.tmatesoft.svn.core.SVNLogEntryPath)4 IOException (java.io.IOException)2 SVNException (org.tmatesoft.svn.core.SVNException)2 SVNRepository (org.tmatesoft.svn.core.io.SVNRepository)2 ArrayList (java.util.ArrayList)1 Node (javafx.scene.Node)1 Label (javafx.scene.control.Label)1 ListCell (javafx.scene.control.ListCell)1 ListView (javafx.scene.control.ListView)1 JDOMException (org.jdom2.JDOMException)1 Nullable (org.jetbrains.annotations.Nullable)1 MCRUsageException (org.mycore.common.MCRUsageException)1