Search in sources :

Example 6 with PropertyData

use of org.jetbrains.idea.svn.properties.PropertyData in project intellij-community by JetBrains.

the class PropertiesComponent method collectProperties.

private static void collectProperties(@NotNull SvnVcs vcs, @NotNull File file, @NotNull final Map<String, String> props) {
    try {
        PropertyConsumer handler = new PropertyConsumer() {

            public void handleProperty(File path, PropertyData property) throws SVNException {
                final PropertyValue value = property.getValue();
                if (value != null) {
                    props.put(property.getName(), PropertyValue.toString(property.getValue()));
                }
            }

            public void handleProperty(SVNURL url, PropertyData property) throws SVNException {
            }

            public void handleProperty(long revision, PropertyData property) throws SVNException {
            }
        };
        vcs.getFactory(file).createPropertyClient().list(SvnTarget.fromFile(file, SVNRevision.UNDEFINED), SVNRevision.WORKING, Depth.EMPTY, handler);
    } catch (VcsException e) {
        props.clear();
    }
}
Also used : PropertyConsumer(org.jetbrains.idea.svn.properties.PropertyConsumer) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) SVNURL(org.tmatesoft.svn.core.SVNURL) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 7 with PropertyData

use of org.jetbrains.idea.svn.properties.PropertyData in project intellij-community by JetBrains.

the class SvnChangeDiffViewerProvider method createPropertyRequest.

@NotNull
private static SvnPropertiesDiffRequest createPropertyRequest(@NotNull Change change, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
    try {
        Change propertiesChange = getSvnChangeLayer(change);
        if (propertiesChange == null)
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        ContentRevision bRevRaw = propertiesChange.getBeforeRevision();
        ContentRevision aRevRaw = propertiesChange.getAfterRevision();
        if (bRevRaw != null && !(bRevRaw instanceof PropertyRevision)) {
            LOG.warn("Before change is not PropertyRevision");
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        }
        if (aRevRaw != null && !(aRevRaw instanceof PropertyRevision)) {
            LOG.warn("After change is not PropertyRevision");
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        }
        PropertyRevision bRev = (PropertyRevision) bRevRaw;
        PropertyRevision aRev = (PropertyRevision) aRevRaw;
        indicator.checkCanceled();
        List<PropertyData> bContent = bRev != null ? bRev.getProperties() : null;
        indicator.checkCanceled();
        List<PropertyData> aContent = aRev != null ? aRev.getProperties() : null;
        if (aRev == null && bRev == null)
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        ContentRevision bRevMain = change.getBeforeRevision();
        ContentRevision aRevMain = change.getAfterRevision();
        String title1 = bRevMain != null ? StringUtil.nullize(bRevMain.getRevisionNumber().asString()) : null;
        String title2 = aRevMain != null ? StringUtil.nullize(aRevMain.getRevisionNumber().asString()) : null;
        return new SvnPropertiesDiffRequest(bContent, aContent, title1, title2);
    } catch (VcsException e) {
        throw new DiffRequestProducerException(e);
    }
}
Also used : DiffRequestProducerException(com.intellij.diff.chains.DiffRequestProducerException) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) PropertyRevision(org.jetbrains.idea.svn.history.PropertyRevision) VcsException(com.intellij.openapi.vcs.VcsException) SvnPropertiesDiffRequest(org.jetbrains.idea.svn.difftool.properties.SvnPropertiesDiffRequest) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with PropertyData

use of org.jetbrains.idea.svn.properties.PropertyData in project intellij-community by JetBrains.

the class SvnPropertiesDiffViewer method collectRecords.

@NotNull
private static List<PropertyRecord> collectRecords(@NotNull SvnPropertiesDiffRequest request) {
    List<DiffContent> originalContents = request.getContents();
    List<PropertyData> properties1 = getProperties(originalContents.get(0));
    List<PropertyData> properties2 = getProperties(originalContents.get(1));
    Map<String, PropertyValue> before = new HashMap<>();
    Map<String, PropertyValue> after = new HashMap<>();
    if (properties1 != null) {
        for (PropertyData data : properties1) {
            before.put(data.getName(), data.getValue());
        }
    }
    if (properties2 != null) {
        for (PropertyData data : properties2) {
            after.put(data.getName(), data.getValue());
        }
    }
    List<PropertyRecord> records = new ArrayList<>();
    for (String name : ContainerUtil.union(before.keySet(), after.keySet())) {
        records.add(createRecord(name, before.get(name), after.get(name)));
    }
    ContainerUtil.sort(records, (o1, o2) -> StringUtil.naturalCompare(o1.getName(), o2.getName()));
    return records;
}
Also used : PropertyData(org.jetbrains.idea.svn.properties.PropertyData) HashMap(com.intellij.util.containers.hash.HashMap) ArrayList(java.util.ArrayList) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) DiffContent(com.intellij.diff.contents.DiffContent) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PropertyData (org.jetbrains.idea.svn.properties.PropertyData)8 NotNull (org.jetbrains.annotations.NotNull)6 PropertyConsumer (org.jetbrains.idea.svn.properties.PropertyConsumer)4 VcsException (com.intellij.openapi.vcs.VcsException)3 File (java.io.File)3 PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)3 SVNURL (org.tmatesoft.svn.core.SVNURL)3 ArrayList (java.util.ArrayList)2 DiffRequestProducerException (com.intellij.diff.chains.DiffRequestProducerException)1 DiffContent (com.intellij.diff.contents.DiffContent)1 EmptyContent (com.intellij.diff.contents.EmptyContent)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Change (com.intellij.openapi.vcs.changes.Change)1 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)1 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 HashMap (com.intellij.util.containers.HashMap)1 HashMap (com.intellij.util.containers.hash.HashMap)1 TreeSet (java.util.TreeSet)1 SvnPropertiesDiffRequest (org.jetbrains.idea.svn.difftool.properties.SvnPropertiesDiffRequest)1