mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-81263 Register sub-root in the current project after clone
This commit is contained in:
@@ -50,6 +50,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.vcs.log.TimedVcsCommit;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.intellij.images.editor.ImageFileEditor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -281,6 +282,13 @@ public class DvcsUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void addMappingIfSubRoot(@NotNull Project project, @NotNull String newRepositoryPath, @NotNull String vcsName) {
|
||||
if (FileUtil.isAncestor(project.getBasePath(), newRepositoryPath, true)) {
|
||||
ProjectLevelVcsManager manager = ProjectLevelVcsManager.getInstance(project);
|
||||
manager.setDirectoryMappings(VcsUtil.addMapping(manager.getDirectoryMappings(), newRepositoryPath, vcsName));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Updater implements Consumer<Object> {
|
||||
private final Repository myRepository;
|
||||
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
package git4idea.checkout;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.dvcs.ui.DvcsBundle;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.CheckoutProvider;
|
||||
import com.intellij.openapi.vcs.VcsNotifier;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
@@ -89,7 +91,7 @@ public class GitCheckoutProvider implements CheckoutProvider {
|
||||
if (!cloneResult.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DvcsUtil.addMappingIfSubRoot(project, FileUtil.join(parentDirectory, directoryName), GitVcs.NAME);
|
||||
destinationParent.refresh(true, true, new Runnable() {
|
||||
public void run() {
|
||||
if (project.isOpen() && (!project.isDisposed()) && (!project.isDefault())) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.zmlx.hg4idea.provider;
|
||||
|
||||
import com.intellij.dvcs.DvcsUtil;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -67,9 +68,12 @@ public class HgCheckoutProvider implements CheckoutProvider {
|
||||
new HgCommandResultNotifier(project).notifyError(cloneResult.get(), "Clone failed",
|
||||
"Clone from " + sourceRepositoryURL + " failed.");
|
||||
}
|
||||
else if (listener != null) {
|
||||
listener.directoryCheckedOut(new File(dialog.getParentDirectory(), dialog.getDirectoryName()), HgVcs.getKey());
|
||||
listener.checkoutCompleted();
|
||||
else {
|
||||
DvcsUtil.addMappingIfSubRoot(project, targetDir, HgVcs.VCS_NAME);
|
||||
if (listener != null) {
|
||||
listener.directoryCheckedOut(new File(dialog.getParentDirectory(), dialog.getDirectoryName()), HgVcs.getKey());
|
||||
listener.checkoutCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
}.queue();
|
||||
|
||||
Reference in New Issue
Block a user