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);
}
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();
}
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));
}
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();
}
Aggregations