Search in sources :

Example 6 with PropertyValue

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

the class SvnMergeProvider method isBinary.

public boolean isBinary(@NotNull final VirtualFile file) {
    SvnVcs vcs = SvnVcs.getInstance(myProject);
    try {
        File ioFile = virtualToIoFile(file);
        PropertyClient client = vcs.getFactory(ioFile).createPropertyClient();
        PropertyValue value = client.getProperty(SvnTarget.fromFile(ioFile), SvnPropertyKeys.SVN_MIME_TYPE, false, SVNRevision.WORKING);
        if (value != null && isBinaryMimeType(value.toString())) {
            return true;
        }
    } catch (VcsException e) {
        LOG.warn(e);
    }
    return false;
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) 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) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

Example 7 with PropertyValue

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

the class SvnVcs method getPropertyWithCaching.

@Nullable
public PropertyValue getPropertyWithCaching(final VirtualFile file, final String propName) throws VcsException {
    Map<String, Pair<PropertyValue, Trinity<Long, Long, Long>>> cachedMap = myPropertyCache.get(keyForVf(file));
    final Pair<PropertyValue, Trinity<Long, Long, Long>> cachedValue = cachedMap == null ? null : cachedMap.get(propName);
    final File ioFile = virtualToIoFile(file);
    final Trinity<Long, Long, Long> tsTrinity = getTimestampForPropertiesChange(ioFile, file.isDirectory());
    if (cachedValue != null) {
        // zero means that a file was not found
        if (trinitiesEqual(cachedValue.getSecond(), tsTrinity)) {
            return cachedValue.getFirst();
        }
    }
    PropertyClient client = getFactory(ioFile).createPropertyClient();
    final PropertyValue value = client.getProperty(SvnTarget.fromFile(ioFile, SVNRevision.WORKING), propName, false, SVNRevision.WORKING);
    if (cachedMap == null) {
        cachedMap = new HashMap<>();
        myPropertyCache.put(keyForVf(file), cachedMap);
    }
    cachedMap.put(propName, Pair.create(value, tsTrinity));
    return value;
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) Trinity(com.intellij.openapi.util.Trinity) 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) Pair(com.intellij.openapi.util.Pair) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with PropertyValue

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

the class SvnDiffProvider method getCommitMessage.

@Nullable
private String getCommitMessage(@NotNull File path, @NotNull Info info) {
    String result;
    try {
        PropertyValue property = myVcs.getFactory(path).createPropertyClient().getProperty(SvnTarget.fromFile(path), COMMIT_MESSAGE, true, info.getCommittedRevision());
        result = PropertyValue.toString(property);
    } catch (VcsException e) {
        LOG.info("Failed to get commit message for file " + path + ", " + info.getCommittedRevision() + ", " + info.getRevision(), e);
        result = "";
    }
    return result;
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) Nullable(org.jetbrains.annotations.Nullable)

Example 9 with PropertyValue

use of org.jetbrains.idea.svn.properties.PropertyValue 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 10 with PropertyValue

use of org.jetbrains.idea.svn.properties.PropertyValue 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

PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)13 VcsException (com.intellij.openapi.vcs.VcsException)6 File (java.io.File)6 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 NotNull (org.jetbrains.annotations.NotNull)4 PropertyClient (org.jetbrains.idea.svn.properties.PropertyClient)4 Nullable (org.jetbrains.annotations.Nullable)3 PropertyData (org.jetbrains.idea.svn.properties.PropertyData)3 SvnTarget (org.tmatesoft.svn.core.wc2.SvnTarget)3 SVNURL (org.tmatesoft.svn.core.SVNURL)2 DiffContent (com.intellij.diff.contents.DiffContent)1 EmptyContent (com.intellij.diff.contents.EmptyContent)1 Pair (com.intellij.openapi.util.Pair)1 Trinity (com.intellij.openapi.util.Trinity)1 HashMap (com.intellij.util.containers.HashMap)1 HashMap (com.intellij.util.containers.hash.HashMap)1 ArrayList (java.util.ArrayList)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 ClientFactory (org.jetbrains.idea.svn.api.ClientFactory)1