mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-75033 Implemented feature to automatically switch directory on new branch creation
This commit is contained in:
@@ -458,6 +458,8 @@ compare.with.branch.list.error=Error Loading Branches
|
||||
create.branch.invalid.revision.error=Invalid revision ''{0}''
|
||||
create.branch.no.working.copy.error=No working copy found at {0}
|
||||
create.branch.no.base.location.error=No branch base location selected
|
||||
create.branch.switch.on.create.title=Switch after create
|
||||
action.name.switch=Switch
|
||||
import.dialog.title=Import into Subversion
|
||||
import.dialog.button=Import
|
||||
repository.browser.add.location.action=Add Repository Location
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
import org.jetbrains.idea.svn.SvnStatusUtil;
|
||||
@@ -37,6 +38,8 @@ import org.jetbrains.idea.svn.SvnVcs;
|
||||
import org.jetbrains.idea.svn.checkin.IdeaCommitHandler;
|
||||
import org.jetbrains.idea.svn.commandLine.CommitEventHandler;
|
||||
import org.jetbrains.idea.svn.dialogs.CreateBranchOrTagDialog;
|
||||
import org.jetbrains.idea.svn.update.AutoSvnUpdater;
|
||||
import org.jetbrains.idea.svn.update.SingleRootSwitcher;
|
||||
import org.tmatesoft.svn.core.SVNErrorCode;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.SVNURL;
|
||||
@@ -125,6 +128,13 @@ public class CreateBranchOrTagAction extends BasicAction {
|
||||
if (!exception.isNull()) {
|
||||
throw new VcsException(exception.get());
|
||||
}
|
||||
|
||||
if (dialog.isCopyFromWorkingCopy() && dialog.isSwitchOnCreate()) {
|
||||
SingleRootSwitcher switcher =
|
||||
new SingleRootSwitcher(project, VcsUtil.getFilePath(srcFile, srcFile.isDirectory()), dstSvnUrl.toDecodedString());
|
||||
|
||||
AutoSvnUpdater.run(switcher, SvnBundle.message("action.name.switch"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.idea.svn.dialogs.CreateBranchOrTagDialog">
|
||||
<grid id="9287c" binding="myTopPanel" layout-manager="GridBagLayout">
|
||||
<constraints>
|
||||
<xy x="10" y="10" width="561" height="470"/>
|
||||
<xy x="10" y="10" width="561" height="502"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -26,7 +26,7 @@
|
||||
</component>
|
||||
</children>
|
||||
</scrollpane>
|
||||
<grid id="9317" layout-manager="GridLayoutManager" row-count="6" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="9317" layout-manager="GridLayoutManager" row-count="7" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -55,7 +55,7 @@
|
||||
</component>
|
||||
<component id="27881" class="javax.swing.JRadioButton" binding="myRepositoryRadioButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Repository Location:"/>
|
||||
@@ -63,13 +63,13 @@
|
||||
</component>
|
||||
<component id="d7ae0" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myRepositoryField">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="0" fill="3" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="675da" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Re&vision:"/>
|
||||
@@ -77,17 +77,17 @@
|
||||
</component>
|
||||
<nested-form id="23004" form-file="org/jetbrains/idea/svn/update/SvnRevisionPanel.form" binding="myRevisionPanel">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</nested-form>
|
||||
<hspacer id="b36ab">
|
||||
<constraints>
|
||||
<grid row="5" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="6" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
<component id="13071" class="javax.swing.JButton" binding="myProjectButton">
|
||||
<constraints>
|
||||
<grid row="4" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<margin top="2" left="2" bottom="2" right="2"/>
|
||||
@@ -103,6 +103,15 @@
|
||||
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="dialog.create.branch.or.tag.from.working.copy.warning"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ff73f" class="com.intellij.ui.components.JBCheckBox" binding="mySwitchOnCreate">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<margin top="0" left="-1" bottom="2" right="3"/>
|
||||
<text resource-bundle="org/jetbrains/idea/svn/SvnBundle" key="create.branch.switch.on.create.title"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="a6551" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.ComboboxWithBrowseButton;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -81,6 +82,7 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
|
||||
private JButton myProjectButton;
|
||||
private JLabel myErrorLabel;
|
||||
private JLabel myUseThisVariantToLabel;
|
||||
private JBCheckBox mySwitchOnCreate;
|
||||
|
||||
@NonNls private static final String HELP_ID = "vcs.subversion.branch";
|
||||
private SvnBranchConfigurationNew myBranchConfiguration;
|
||||
@@ -236,6 +238,7 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
|
||||
|
||||
private void updateControls() {
|
||||
myWorkingCopyField.setEnabled(myWorkingCopyRadioButton.isSelected());
|
||||
mySwitchOnCreate.setEnabled(myWorkingCopyRadioButton.isSelected());
|
||||
myRepositoryField.setEnabled(myRepositoryRadioButton.isSelected());
|
||||
myRevisionPanel.setEnabled(myRepositoryRadioButton.isSelected());
|
||||
myProjectButton.setEnabled(myRepositoryRadioButton.isSelected());
|
||||
@@ -369,4 +372,8 @@ public class CreateBranchOrTagDialog extends DialogWrapper {
|
||||
public String getCopyFromUrl() {
|
||||
return myRepositoryField.getText();
|
||||
}
|
||||
|
||||
public boolean isSwitchOnCreate() {
|
||||
return mySwitchOnCreate.isSelected();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,16 @@ public class AutoSvnUpdater extends AbstractCommonUpdateAction {
|
||||
configuration17.setUpdateDepth(SVNDepth.INFINITY);
|
||||
final SvnVcs vcs = SvnVcs.getInstance(myProject);
|
||||
for (FilePath root : myRoots) {
|
||||
final UpdateRootInfo info = configuration17.getUpdateRootInfo(root.getIOFile(), vcs);
|
||||
info.setRevision(SVNRevision.HEAD);
|
||||
info.setUpdateToRevision(false);
|
||||
configureUpdateRootInfo(root, configuration17.getUpdateRootInfo(root.getIOFile(), vcs));
|
||||
}
|
||||
super.actionPerformed(context);
|
||||
}
|
||||
|
||||
protected void configureUpdateRootInfo(@NotNull FilePath root, @NotNull UpdateRootInfo info) {
|
||||
info.setRevision(SVNRevision.HEAD);
|
||||
info.setUpdateToRevision(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean filterRootsBeforeAction() {
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.svn.update;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Konstantin Kolosovsky.
|
||||
*/
|
||||
public class SingleRootSwitcher extends AutoSvnUpdater {
|
||||
|
||||
@NotNull private String myUrl;
|
||||
|
||||
public SingleRootSwitcher(Project project, @NotNull FilePath root, @NotNull String url) {
|
||||
super(project, new FilePath[]{root});
|
||||
|
||||
myUrl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureUpdateRootInfo(@NotNull FilePath root, @NotNull UpdateRootInfo info) {
|
||||
super.configureUpdateRootInfo(root, info);
|
||||
|
||||
info.setUrl(myUrl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user