Search in sources :

Example 6 with PropertyClient

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

Aggregations

PropertyClient (org.jetbrains.idea.svn.properties.PropertyClient)6 File (java.io.File)5 VcsException (com.intellij.openapi.vcs.VcsException)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 PropertyValue (org.jetbrains.idea.svn.properties.PropertyValue)4 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 Nullable (org.jetbrains.annotations.Nullable)2 Pair (com.intellij.openapi.util.Pair)1 Trinity (com.intellij.openapi.util.Trinity)1 TreeSet (java.util.TreeSet)1 SvnVcs (org.jetbrains.idea.svn.SvnVcs)1 SetPropertyDialog (org.jetbrains.idea.svn.dialogs.SetPropertyDialog)1 PropertyConsumer (org.jetbrains.idea.svn.properties.PropertyConsumer)1 PropertyData (org.jetbrains.idea.svn.properties.PropertyData)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1