com.intellij.openapi.vfs.VirtualFileorg.zmlx.hg4idea.repo.HgRepository



Project JetBrains/intellij-community in file ...idea.src.org.zmlx.hg4idea.action.HgPullAction.java (2014-02-27)
@@ -16,10 +16,10 @@ import com.intellij.icons.AllIcons;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.zmlx.hg4idea.command.HgPullCommand;
+import org.zmlx.hg4idea.repo.HgRepository;
 import org.zmlx.hg4idea.ui.HgPullDialog;
 
 import java.util.Collection;
@@ -30,9 +30,8 @@ public class HgPullAction extends HgAbstractGlobalAction {
   }
 
   @Override
-  protected void execute(@NotNull final Project project, @NotNull Collection<VirtualFile> repos, @Nullable VirtualFile selectedRepo) {
-    final HgPullDialog dialog = new HgPullDialog(project);
-    dialog.setRoots(repos, selectedRepo);
+  protected void execute(@NotNull final Project project, @NotNull Collection<HgRepository> repos, @Nullable HgRepository selectedRepo) {
+    final HgPullDialog dialog = new HgPullDialog(project, repos, selectedRepo);
     dialog.show();
     if (dialog.isOK()) {
       dialog.rememberSettings();
Project JetBrains/intellij-community in file ....src.org.zmlx.hg4idea.command.HgRebaseCommand.java (2014-03-11)
@@ -13,32 +13,34 @@
 package org.zmlx.hg4idea.command;
 
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.zmlx.hg4idea.HgVcs;
 import org.zmlx.hg4idea.execution.HgCommandExecutor;
 import org.zmlx.hg4idea.execution.HgCommandResult;
+import org.zmlx.hg4idea.repo.HgRepository;
 
 import java.util.Arrays;
 
 public class HgRebaseCommand {
 
-  private final Project project;
-  private final VirtualFile repo;
+  @NotNull private final Project project;
+  @NotNull private final HgRepository repo;
 
-  public HgRebaseCommand(Project project, @NotNull VirtualFile repo) {
+  public HgRebaseCommand(@NotNull Project project, @NotNull HgRepository repo) {
     this.project = project;
     this.repo = repo;
   }
 
   public HgCommandResult continueRebase() {
-    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repo, "rebase", Arrays.asList("--continue"), null);
+    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", Arrays.asList("--continue"), null);
+    repo.update();
     project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null);
     return result;
   }
 
   public HgCommandResult abortRebase() {
-    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repo, "rebase", Arrays.asList("--abort"), null);
+    HgCommandResult result = new HgCommandExecutor(project).executeInCurrentThread(repo.getRoot(), "rebase", Arrays.asList("--abort"), null);
+    repo.update();
     project.getMessageBus().syncPublisher(HgVcs.BRANCH_TOPIC).update(project, null);
     return result;
   }
Project JetBrains/intellij-community in file ...src.org.zmlx.hg4idea.action.HgCreateTagAction.java (2014-02-27)
@@ -13,13 +13,13 @@
 package org.zmlx.hg4idea.action;
 
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.zmlx.hg4idea.command.HgTagCreateCommand;
 import org.zmlx.hg4idea.execution.HgCommandException;
 import org.zmlx.hg4idea.execution.HgCommandResult;
 import org.zmlx.hg4idea.execution.HgCommandResultHandler;
+import org.zmlx.hg4idea.repo.HgRepository;
 import org.zmlx.hg4idea.ui.HgTagDialog;
 import org.zmlx.hg4idea.util.HgErrorUtil;
 
@@ -28,11 +28,10 @@ import java.util.Collection;
 public class HgCreateTagAction extends HgAbstractGlobalAction {
 
   public void execute(@NotNull final Project project,
-                      @NotNull Collection<VirtualFile> repos,
-                      @Nullable VirtualFile selectedRepo,
+                      @NotNull Collection<HgRepository> repositories,
+                      @Nullable HgRepository selectedRepo,
                       @Nullable final String reference) {
-    final HgTagDialog dialog = new HgTagDialog(project);
-    dialog.setRoots(repos, selectedRepo);
+    final HgTagDialog dialog = new HgTagDialog(project, repositories, selectedRepo);
     dialog.show();
     if (dialog.isOK()) {
       try {
@@ -52,7 +51,9 @@ public class HgCreateTagAction extends HgAbstractGlobalAction {
     }
   }
 
-  protected void execute(@NotNull final Project project, @NotNull Collection<VirtualFile> repos, @Nullable VirtualFile selectedRepo) {
-    execute(project, repos, selectedRepo, null);
+  protected void execute(@NotNull final Project project,
+                         @NotNull Collection<HgRepository> repositories,
+                         @Nullable HgRepository selectedRepo) {
+    execute(project, repositories, selectedRepo, null);
   }
 }
Project JetBrains/intellij-community in file ...lx.hg4idea.action.HgRunConflictResolverAction.java (2014-02-27)
@@ -15,11 +15,11 @@ package org.zmlx.hg4idea.action;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.zmlx.hg4idea.HgVcsMessages;
 import org.zmlx.hg4idea.provider.update.HgConflictResolver;
+import org.zmlx.hg4idea.repo.HgRepository;
 import org.zmlx.hg4idea.ui.HgRunConflictResolverDialog;
 
 import java.util.Collection;
@@ -27,13 +27,13 @@ import java.util.Collection;
 public class HgRunConflictResolverAction extends HgAbstractGlobalAction {
 
   @Override
-  public void execute(@NotNull final Project project, @NotNull Collection<VirtualFile> repos, @Nullable VirtualFile selectedRepo) {
-    final VirtualFile repository;
-    if (repos.size() > 1) {
-      repository = letUserSelectRepository(repos, project, selectedRepo);
+  public void execute(@NotNull final Project project, @NotNull Collection<HgRepository> repositories, @Nullable HgRepository selectedRepo) {
+    final HgRepository repository;
+    if (repositories.size() > 1) {
+      repository = letUserSelectRepository(project, repositories, selectedRepo);
     }
-    else if (repos.size() == 1) {
-      repository = repos.iterator().next();
+    else if (repositories.size() == 1) {
+      repository = repositories.iterator().next();
     }
     else {
       repository = null;
@@ -43,17 +43,18 @@ public class HgRunConflictResolverAction extends HgAbstractGlobalAction {
 
         @Override
         public void run(@NotNull ProgressIndicator indicator) {
-          new HgConflictResolver(project).resolve(repository);
-          markDirtyAndHandleErrors(project, repository);
+          new HgConflictResolver(project).resolve(repository.getRoot());
+          markDirtyAndHandleErrors(project, repository.getRoot());
         }
       }.queue();
     }
   }
 
 
-  private static VirtualFile letUserSelectRepository(Collection<VirtualFile> repos, Project project, @Nullable VirtualFile selectedRepo) {
-    HgRunConflictResolverDialog dialog = new HgRunConflictResolverDialog(project);
-    dialog.setRoots(repos, selectedRepo);
+  @Nullable
+  private static HgRepository letUserSelectRepository(@NotNull Project project, @NotNull Collection<HgRepository> repositories,
+                                                      @Nullable HgRepository selectedRepo) {
+    HgRunConflictResolverDialog dialog = new HgRunConflictResolverDialog(project, repositories, selectedRepo);
     dialog.show();
     if (dialog.isOK()) {
       return dialog.getRepository();
Project JetBrains/intellij-community in file ...zmlx.hg4idea.ui.HgRepositorySelectorComponent.java (2014-02-27)
@@ -12,10 +12,10 @@
 // limitations under the License.
 package org.zmlx.hg4idea.ui;
 
-import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.IdeBorderFactory;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.zmlx.hg4idea.repo.HgRepository;
 
 import javax.swing.*;
 import java.awt.event.ActionListener;
@@ -25,54 +25,31 @@ public class HgRepositorySelectorComponent {
   private JComboBox repositorySelector;
   private JPanel mainPanel;
 
-  public void setRoots(Collection<VirtualFile> roots) {
+  public void setRoots(Collection<HgRepository> roots) {
     DefaultComboBoxModel model = new DefaultComboBoxModel();
-    for (VirtualFile repo : roots) {
-      model.addElement(new RepositoryDisplay(repo));
+    for (HgRepository repo : roots) {
+      model.addElement(repo);
     }
     repositorySelector.setModel(model);
     mainPanel.setVisible(roots.size() > 1);
   }
 
-  public void setSelectedRoot(@Nullable VirtualFile repository) {
+  public void setSelectedRoot(@Nullable HgRepository repository) {
     if (repository != null) {
-      repositorySelector.setSelectedItem(new RepositoryDisplay(repository));
+      repositorySelector.setSelectedItem(repository);
     }
   }
 
-  public void addActionListener(ActionListener actionListener) {
+  public void addActionListener(@NotNull ActionListener actionListener) {
     repositorySelector.addActionListener(actionListener);
   }
 
-  public void setTitle(String title) {
+  public void setTitle(@NotNull String title) {
     mainPanel.setBorder(IdeBorderFactory.createTitledBorder(title, true));
   }
 
-  public VirtualFile getRepository() {
-    return ((RepositoryDisplay) repositorySelector.getSelectedItem()).repo;
+  @NotNull
+  public HgRepository getRepository() {
+    return (HgRepository)repositorySelector.getSelectedItem();
   }
-
-  private class RepositoryDisplay {
-    @NotNull private final VirtualFile repo;
-
-    public RepositoryDisplay(@NotNull VirtualFile repo) {
-      this.repo = repo;
-    }
-
-    @Override
-    public String toString() {
-      return repo.getPresentableUrl();
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-      return obj instanceof RepositoryDisplay && this.repo.equals(((RepositoryDisplay)obj).repo);
-    }
-
-    @Override
-    public int hashCode() {
-      return repo.hashCode();
-    }
-  }
-
 }