Search in sources :

Example 26 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgRepositorySelectorComponent method setRoots.

public void setRoots(Collection<HgRepository> roots) {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (HgRepository repo : roots) {
        model.addElement(repo);
    }
    repositorySelector.setModel(model);
    mainPanel.setVisible(roots.size() > 1);
}
Also used : HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Example 27 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgRegularUpdater method commitOrWarnAboutConflicts.

private void commitOrWarnAboutConflicts(List<VcsException> exceptions, HgCommandResult mergeResult) throws VcsException {
    if (mergeResult.getExitValue() == 0) {
        //operation successful and no conflicts
        try {
            HgRepository hgRepository = HgUtil.getRepositoryForFile(project, repoRoot);
            if (hgRepository == null) {
                LOG.warn("Couldn't find repository info for " + repoRoot.getName());
                return;
            }
            new HgCommitCommand(project, hgRepository, "Automated merge").executeInCurrentThread();
        } catch (HgCommandException e) {
            throw new VcsException(e);
        }
    } else {
        reportWarning(exceptions, HgVcsMessages.message("hg4idea.update.warning.merge.conflicts", repoRoot.getPath()));
    }
}
Also used : VcsException(com.intellij.openapi.vcs.VcsException) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgCommandException(org.zmlx.hg4idea.execution.HgCommandException)

Example 28 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgTaskBranchesTest method initRepository.

@NotNull
@Override
protected Repository initRepository(@NotNull String name) {
    String tempDirectory = FileUtil.getTempDirectory();
    String root = tempDirectory + "/" + name;
    assertTrue(new File(root).mkdirs());
    HgPlatformTest.initRepo(root);
    touch("a.txt");
    hg("add a.txt");
    hg("commit -m another -u abc");
    hg("up -r 0");
    ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(myProject);
    HgVcs hgVcs = HgVcs.getInstance(myProject);
    assert hgVcs != null;
    hgVcs.getProjectSettings().setCheckIncomingOutgoing(false);
    vcsManager.setDirectoryMapping(root, HgVcs.VCS_NAME);
    VirtualFile file = LocalFileSystem.getInstance().findFileByIoFile(new File(root));
    HgRepository repository = HgUtil.getRepositoryManager(myProject).getRepositoryForRoot(file);
    assertNotNull("Couldn't find repository for root " + root, repository);
    return repository;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgVcs(org.zmlx.hg4idea.HgVcs) ProjectLevelVcsManagerImpl(com.intellij.openapi.vcs.impl.ProjectLevelVcsManagerImpl) HgRepository(org.zmlx.hg4idea.repo.HgRepository) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 29 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgBookmarkCommand method createBookmarkAsynchronously.

public static void createBookmarkAsynchronously(@NotNull List<HgRepository> repositories, @NotNull String name, boolean isActive) {
    final Project project = ObjectUtils.assertNotNull(ContainerUtil.getFirstItem(repositories)).getProject();
    if (StringUtil.isEmptyOrSpaces(name)) {
        VcsNotifier.getInstance(project).notifyError("Hg Error", "Bookmark name is empty");
        return;
    }
    new Task.Backgroundable(project, HgVcsMessages.message("hg4idea.progress.bookmark", name)) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            for (HgRepository repository : repositories) {
                executeBookmarkCommandSynchronously(project, repository.getRoot(), name, isActive ? emptyList() : singletonList("--inactive"));
            }
        }
    }.queue();
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.intellij.openapi.progress.Task) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Example 30 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgQGotoFromLogAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
    log.requestSelectedDetails(new Consumer<List<VcsFullCommitDetails>>() {

        @Override
        public void consume(List<VcsFullCommitDetails> selectedDetails) {
            VcsFullCommitDetails fullCommitDetails = ContainerUtil.getFirstItem(selectedDetails);
            assert fullCommitDetails != null;
            final HgRepository repository = getRepositoryForRoot(project, fullCommitDetails.getRoot());
            assert repository != null;
            actionPerformed(repository, fullCommitDetails);
        }
    }, null);
}
Also used : Project(com.intellij.openapi.project.Project) VcsLog(com.intellij.vcs.log.VcsLog) List(java.util.List) HgRepository(org.zmlx.hg4idea.repo.HgRepository) VcsFullCommitDetails(com.intellij.vcs.log.VcsFullCommitDetails)

Aggregations

HgRepository (org.zmlx.hg4idea.repo.HgRepository)36 NotNull (org.jetbrains.annotations.NotNull)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Project (com.intellij.openapi.project.Project)7 VcsException (com.intellij.openapi.vcs.VcsException)5 FilePath (com.intellij.openapi.vcs.FilePath)4 HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 File (java.io.File)3 HgFile (org.zmlx.hg4idea.HgFile)3 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)3 Task (com.intellij.openapi.progress.Task)2 AbstractVcsVirtualFile (com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile)2 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 HgFileRevision (org.zmlx.hg4idea.HgFileRevision)2 HgNameWithHashInfo (org.zmlx.hg4idea.HgNameWithHashInfo)2 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)2