Search in sources :

Example 6 with Repository

use of com.intellij.dvcs.repo.Repository in project intellij-community by JetBrains.

the class PushController method startLoadingCommits.

private void startLoadingCommits() {
    Map<RepositoryNode, MyRepoModel> priorityLoading = ContainerUtil.newLinkedHashMap();
    Map<RepositoryNode, MyRepoModel> others = ContainerUtil.newLinkedHashMap();
    RepositoryNode nodeForCurrentEditor = findNodeByRepo(myCurrentlyOpenedRepository);
    for (Map.Entry<RepositoryNode, MyRepoModel<?, ?, ?>> entry : myView2Model.entrySet()) {
        MyRepoModel model = entry.getValue();
        Repository repository = model.getRepository();
        RepositoryNode repoNode = entry.getKey();
        if (preselectByUser(repository)) {
            priorityLoading.put(repoNode, model);
        } else if (model.getSupport().shouldRequestIncomingChangesForNotCheckedRepositories() && !repoNode.equals(nodeForCurrentEditor)) {
            others.put(repoNode, model);
        }
        if (shouldPreSelect(model)) {
            model.setChecked(true);
        }
    }
    if (nodeForCurrentEditor != null) {
        //add repo for currently opened editor to the end of priority queue
        priorityLoading.put(nodeForCurrentEditor, myView2Model.get(nodeForCurrentEditor));
    }
    loadCommitsFromMap(priorityLoading);
    loadCommitsFromMap(others);
}
Also used : Repository(com.intellij.dvcs.repo.Repository)

Example 7 with Repository

use of com.intellij.dvcs.repo.Repository in project intellij-community by JetBrains.

the class VcsPushAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    VcsRepositoryManager manager = VcsRepositoryManager.getInstance(project);
    Collection<Repository> repositories = e.getData(CommonDataKeys.EDITOR) != null ? ContainerUtil.<Repository>emptyList() : collectRepositories(manager, e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY));
    VirtualFile selectedFile = DvcsUtil.getSelectedFile(project);
    new VcsPushDialog(project, DvcsUtil.sortRepositories(repositories), selectedFile != null ? manager.getRepositoryForFile(selectedFile) : null).show();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Repository(com.intellij.dvcs.repo.Repository) VcsPushDialog(com.intellij.dvcs.push.ui.VcsPushDialog) VcsRepositoryManager(com.intellij.dvcs.repo.VcsRepositoryManager)

Example 8 with Repository

use of com.intellij.dvcs.repo.Repository in project intellij-community by JetBrains.

the class TaskBranchesTest method testVcsTaskHandler.

public void testVcsTaskHandler() throws Exception {
    List<Repository> repositories = initRepositories("community", "idea");
    Repository repository = repositories.get(0);
    String defaultBranchName = getDefaultBranchName();
    assertEquals(defaultBranchName, repository.getCurrentBranchName());
    VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(getProject());
    assertEquals(1, handlers.length);
    VcsTaskHandler handler = handlers[0];
    VcsTaskHandler.TaskInfo defaultInfo = handler.getAllExistingTasks()[0];
    assertEquals(defaultBranchName, defaultInfo.getName());
    assertEquals(2, defaultInfo.getRepositories().size());
    final String first = "first";
    VcsTaskHandler.TaskInfo firstInfo = handler.startNewTask(first);
    repository.update();
    assertEquals(first, firstInfo.getName());
    assertEquals(2, firstInfo.getRepositories().size());
    assertEquals(2, getNumberOfBranches(repository));
    assertEquals(first, repository.getCurrentBranchName());
    handler.switchToTask(defaultInfo, null);
    repository.update();
    assertEquals(defaultBranchName, repository.getCurrentBranchName());
    final String second = "second";
    VcsTaskHandler.TaskInfo secondInfo = handler.startNewTask(second);
    repository.update();
    assertEquals(3, getNumberOfBranches(repository));
    assertEquals(second, repository.getCurrentBranchName());
    handler.switchToTask(firstInfo, null);
    createAndCommitChanges(repository);
    handler.closeTask(secondInfo, firstInfo);
    repository.update();
    assertEquals(2, getNumberOfBranches(repository));
}
Also used : Repository(com.intellij.dvcs.repo.Repository) VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler)

Example 9 with Repository

use of com.intellij.dvcs.repo.Repository in project intellij-community by JetBrains.

the class VcsRepositoryManagerTest method testRepositoryInfoReadingWhileModifying.

public void testRepositoryInfoReadingWhileModifying() throws Exception {
    final VirtualFile repositoryFile = createExternalRepository();
    assertNotNull(myGlobalRepositoryManager.getRepositoryForRoot(repositoryFile));
    FutureTask<Repository> readExistingRepo = new FutureTask<>(new Callable<Repository>() {

        @Override
        public Repository call() throws Exception {
            return myGlobalRepositoryManager.getRepositoryForRoot(repositoryFile);
        }
    });
    FutureTask<Boolean> modifyRepositoryMapping = new FutureTask<>(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            myProjectLevelVcsManager.setDirectoryMappings(VcsUtil.addMapping(myProjectLevelVcsManager.getDirectoryMappings(), myProjectRoot.getPath(), myVcs.getName()));
            return !myGlobalRepositoryManager.getRepositories().isEmpty();
        }
    });
    Thread modify = new Thread(modifyRepositoryMapping, "vcs modify");
    modify.start();
    //wait until modification starts
    assertTrue(LOCK_ERROR_TEXT, READY_TO_READ.await(1, TimeUnit.SECONDS));
    Thread read = new Thread(readExistingRepo, "vcs read");
    read.start();
    assertNotNull(readExistingRepo.get(1, TimeUnit.SECONDS));
    CONTINUE_MODIFY.countDown();
    assertTrue(modifyRepositoryMapping.get(1, TimeUnit.SECONDS));
    read.join();
    modify.join();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Repository(com.intellij.dvcs.repo.Repository) FutureTask(java.util.concurrent.FutureTask)

Aggregations

Repository (com.intellij.dvcs.repo.Repository)9 LocalTask (com.intellij.tasks.LocalTask)4 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VcsPushDialog (com.intellij.dvcs.push.ui.VcsPushDialog)1 VcsRepositoryManager (com.intellij.dvcs.repo.VcsRepositoryManager)1 Project (com.intellij.openapi.project.Project)1 VcsTaskHandler (com.intellij.openapi.vcs.VcsTaskHandler)1 BranchInfo (com.intellij.tasks.BranchInfo)1 GitRepository (git4idea.repo.GitRepository)1 FutureTask (java.util.concurrent.FutureTask)1