diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java index 513977068b14..3f740bad1bef 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/SetPropertyAction.java @@ -28,9 +28,9 @@ import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnVcs; import org.jetbrains.idea.svn.dialogs.SetPropertyDialog; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.properties.PropertyClient; +import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNPropertyValue; -import org.tmatesoft.svn.core.wc.SVNWCClient; import java.io.File; @@ -73,15 +73,13 @@ public class SetPropertyAction extends BasicAction { String value = dialog.getPropertyValue(); boolean recursive = dialog.isRecursive(); - SVNWCClient wcClient = activeVcs.createWCClient(); for (int i = 0; i < ioFiles.length; i++) { File ioFile = ioFiles[i]; - try { - wcClient.doSetProperty(ioFile, name, SVNPropertyValue.create(value), false, recursive, null); - } - catch (SVNException e) { - throw new VcsException(e); - } + PropertyClient client = activeVcs.getFactory(ioFile).createPropertyClient(); + + // TODO: most likely SVNDepth.getInfinityOrEmptyDepth should be used instead of SVNDepth.fromRecursive - to have either "infinity" + // TODO: or "empty" depth, and not "infinity" or "files" depth. But previous logic used SVNDepth.fromRecursive implicitly + client.setProperty(ioFile, name, SVNPropertyValue.create(value), SVNDepth.fromRecurse(recursive), false); } for(int i = 0; i < file.length; i++) { if (recursive && file[i].isDirectory()) { diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandName.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandName.java index 5985ebf5ed88..af1ef68af323 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandName.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/SvnCommandName.java @@ -41,6 +41,8 @@ public enum SvnCommandName { resolve("resolve", true), propget("propget", false), proplist("proplist", false), + propset("propset", true), + propdel("propdel", true), blame("blame", false), merge("merge", true), changelist("changelist", true), diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java index 486fe2c4355e..421f0a0ce138 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/SetPropertyDialog.java @@ -15,22 +15,26 @@ */ package org.jetbrains.idea.svn.dialogs; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.help.HelpManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.openapi.vcs.VcsException; import com.intellij.ui.DocumentAdapter; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; import org.jetbrains.idea.svn.SvnPropertyKeys; import org.jetbrains.idea.svn.SvnVcs; -import org.tmatesoft.svn.core.SVNException; +import org.jetbrains.idea.svn.properties.PropertyClient; +import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; -import org.tmatesoft.svn.core.wc.SVNWCClient; +import org.tmatesoft.svn.core.wc2.SvnTarget; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -47,6 +51,9 @@ import java.util.TreeSet; * @author alex */ public class SetPropertyDialog extends DialogWrapper { + + private static final Logger LOG = Logger.getInstance("org.jetbrains.idea.svn.dialogs.SetPropertyDialog"); + private final String myPropertyName; private final File[] myFiles; @@ -147,14 +154,8 @@ public class SetPropertyDialog extends DialogWrapper { return; } File file = myFiles[0]; - SVNPropertyData property; - try { - SVNWCClient client = myVCS.createWCClient(); - property = client.doGetProperty(file, name, SVNRevision.WORKING, SVNRevision.WORKING); - } - catch (SVNException e) { - property = null; - } + SVNPropertyData property = !StringUtil.isEmpty(name) ? getProperty(file, name) : null; + if (property != null) { myValueText.setText(SVNPropertyValue.getPropertyAsString(property.getValue())); myValueText.selectAll(); @@ -164,6 +165,21 @@ public class SetPropertyDialog extends DialogWrapper { } } + private SVNPropertyData getProperty(@NotNull File file, @NotNull String name) { + SVNPropertyData property; + + try { + PropertyClient client = myVCS.getFactory(file).createPropertyClient(); + property = client.getProperty(SvnTarget.fromFile(file, SVNRevision.WORKING), name, false, SVNRevision.WORKING); + } + catch (VcsException e) { + LOG.info(e); + property = null; + } + + return property; + } + protected JComponent createCenterPanel() { fillPropertyNames(myFiles); if (myPropertyName != null) { @@ -189,23 +205,26 @@ public class SetPropertyDialog extends DialogWrapper { if (files.length == 1) { File file = files[0]; try { - SVNWCClient client = myVCS.createWCClient(); - client.doGetProperty(file, null, SVNRevision.WORKING, SVNRevision.WORKING, false, - new ISVNPropertyHandler() { - public void handleProperty(File path, SVNPropertyData property) { - String name = property.getName(); - if (name != null) { - names.add(name); - } - } - public void handleProperty(SVNURL url, SVNPropertyData property) { - } - public void handleProperty(long revision, SVNPropertyData property) { - } - }); + ISVNPropertyHandler handler = new ISVNPropertyHandler() { + public void handleProperty(File path, SVNPropertyData property) { + String name = property.getName(); + if (name != null) { + names.add(name); + } + } + + public void handleProperty(SVNURL url, SVNPropertyData property) { + } + + public void handleProperty(long revision, SVNPropertyData property) { + } + }; + + PropertyClient client = myVCS.getFactory(file).createPropertyClient(); + client.list(SvnTarget.fromFile(file, SVNRevision.WORKING), SVNRevision.WORKING, SVNDepth.EMPTY, handler); } - catch (SVNException e) { - // + catch (VcsException e) { + LOG.info(e); } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java index df5230bc6a72..4013f97b7a77 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/CmdPropertyClient.java @@ -88,6 +88,27 @@ public class CmdPropertyClient extends BaseSvnClient implements PropertyClient { parseOutput(target, command.getOutput(), handler); } + @Override + public void setProperty(@NotNull File file, + @NotNull String property, + @Nullable SVNPropertyValue value, + @Nullable SVNDepth depth, + boolean force) throws VcsException { + List parameters = new ArrayList(); + boolean isDelete = value == null; + + parameters.add(property); + if (!isDelete) { + parameters.add(SVNPropertyValue.getPropertyAsString(value)); + // --force could only be used in "propset" command, but not in "propdel" command + CommandUtil.put(parameters, force, "--force"); + } + CommandUtil.put(parameters, file); + CommandUtil.put(parameters, depth); + + CommandUtil.execute(myVcs, isDelete ? SvnCommandName.propdel : SvnCommandName.propset, parameters, null); + } + private void fillListParameters(@NotNull SvnTarget target, @Nullable SVNRevision revision, @Nullable SVNDepth depth, diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java index 6e12f738ac87..2f1ba5ea7790 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/PropertyClient.java @@ -5,11 +5,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.SvnClient; import org.tmatesoft.svn.core.SVNDepth; +import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; import org.tmatesoft.svn.core.wc.SVNRevision; import org.tmatesoft.svn.core.wc2.SvnTarget; +import java.io.File; + /** * @author Konstantin Kolosovsky. */ @@ -30,4 +33,10 @@ public interface PropertyClient extends SvnClient { @Nullable SVNRevision revision, @Nullable SVNDepth depth, @Nullable ISVNPropertyHandler handler) throws VcsException; + + void setProperty(@NotNull File file, + @NotNull String property, + @Nullable SVNPropertyValue value, + @Nullable SVNDepth depth, + boolean force) throws VcsException; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java index ef3c1b3888ee..ee72e59718ef 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/properties/SvnKitPropertyClient.java @@ -4,8 +4,10 @@ import com.intellij.openapi.vcs.VcsException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.svn.api.BaseSvnClient; +import org.jetbrains.idea.svn.commandLine.SvnBindException; import org.tmatesoft.svn.core.SVNDepth; import org.tmatesoft.svn.core.SVNException; +import org.tmatesoft.svn.core.SVNPropertyValue; import org.tmatesoft.svn.core.SVNURL; import org.tmatesoft.svn.core.wc.ISVNPropertyHandler; import org.tmatesoft.svn.core.wc.SVNPropertyData; @@ -59,6 +61,20 @@ public class SvnKitPropertyClient extends BaseSvnClient implements PropertyClien runGetProperty(target, null, revision, depth, handler); } + @Override + public void setProperty(@NotNull File file, + @NotNull String property, + @Nullable SVNPropertyValue value, + @Nullable SVNDepth depth, + boolean force) throws VcsException { + try { + myVcs.createWCClient().doSetProperty(file, property, value, force, depth, null, null); + } + catch (SVNException e) { + throw new SvnBindException(e); + } + } + private void runGetProperty(@NotNull SvnTarget target, @Nullable String property, @Nullable SVNRevision revision,