Search in sources :

Example 1 with PropertyValue

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

the class SvnEditFileProvider method editFiles.

public void editFiles(VirtualFile[] files) throws VcsException {
    File[] ioFiles = new File[files.length];
    for (int i = 0; i < files.length; i++) {
        ioFiles[i] = virtualToIoFile(files[i]);
        PropertyClient client = myVCS.getFactory(ioFiles[i]).createPropertyClient();
        PropertyValue property = client.getProperty(SvnTarget.fromFile(ioFiles[i], SVNRevision.WORKING), SvnPropertyKeys.SVN_NEEDS_LOCK, false, SVNRevision.WORKING);
        if (property == null) {
            throw new VcsException(SvnBundle.message("exception.text.file.miss.svn", ioFiles[i].getName()));
        }
    }
    SvnUtil.doLockFiles(myVCS.getProject(), myVCS, ioFiles);
}
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) File(java.io.File) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)

Example 2 with PropertyValue

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

the class CreateExternalAction method addToExternalProperty.

public static void addToExternalProperty(@NotNull SvnVcs vcs, @NotNull File ioFile, String target, String url) throws VcsException {
    ClientFactory factory = vcs.getFactory(ioFile);
    PropertyValue propertyValue = factory.createPropertyClient().getProperty(SvnTarget.fromFile(ioFile), SvnPropertyKeys.SVN_EXTERNALS, false, SVNRevision.UNDEFINED);
    boolean hasExternals = propertyValue != null && !isEmptyOrSpaces(propertyValue.toString());
    String newExternals = "";
    if (hasExternals) {
        String externalsForTarget = parseExternalsProperty(propertyValue.toString()).get(target);
        if (externalsForTarget != null) {
            throw new VcsException("Selected destination conflicts with existing: " + externalsForTarget);
        }
        newExternals = propertyValue.toString().trim() + "\n";
    }
    newExternals += escape(url) + " " + target;
    factory.createPropertyClient().setProperty(ioFile, SvnPropertyKeys.SVN_EXTERNALS, PropertyValue.create(newExternals), Depth.EMPTY, false);
}
Also used : ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue)

Example 3 with PropertyValue

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

the class SvnDiffViewer method getProperties.

@NotNull
private static Map<String, PropertyValue> getProperties(@NotNull DiffContent content) {
    if (content instanceof EmptyContent)
        return Collections.emptyMap();
    List<PropertyData> properties = ((SvnPropertiesDiffRequest.PropertyContent) content).getProperties();
    Map<String, PropertyValue> map = new HashMap<>();
    for (PropertyData data : properties) {
        if (map.containsKey(data.getName()))
            LOG.warn("Duplicated property: " + data.getName());
        map.put(data.getName(), data.getValue());
    }
    return map;
}
Also used : PropertyData(org.jetbrains.idea.svn.properties.PropertyData) HashMap(com.intellij.util.containers.HashMap) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) EmptyContent(com.intellij.diff.contents.EmptyContent) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with PropertyValue

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

the class SetPropertyDialog method updatePropertyValue.

private void updatePropertyValue(String name) {
    if (myFiles.length == 0 || myFiles.length > 1) {
        return;
    }
    File file = myFiles[0];
    PropertyValue property = !StringUtil.isEmpty(name) ? getProperty(file, name) : null;
    if (property != null) {
        myValueText.setText(property.toString());
        myValueText.selectAll();
    } else {
        myValueText.setText("");
    }
}
Also used : PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) File(java.io.File)

Example 5 with PropertyValue

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

the class SetPropertyDialog method getProperty.

@Nullable
private PropertyValue getProperty(@NotNull File file, @NotNull String name) {
    PropertyValue result;
    try {
        PropertyClient client = myVCS.getFactory(file).createPropertyClient();
        result = client.getProperty(SvnTarget.fromFile(file, SVNRevision.WORKING), name, false, SVNRevision.WORKING);
    } catch (VcsException e) {
        LOG.info(e);
        result = null;
    }
    return result;
}
Also used : PropertyClient(org.jetbrains.idea.svn.properties.PropertyClient) VcsException(com.intellij.openapi.vcs.VcsException) PropertyValue(org.jetbrains.idea.svn.properties.PropertyValue) Nullable(org.jetbrains.annotations.Nullable)

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