private static void correctListForRevision( final ProjectLevelVcsManager plVcsManager, final ContentRevision revision, final SVNChangelistClient client, final String name) { if (revision != null) { final FilePath path = revision.getFile(); final AbstractVcs vcs = plVcsManager.getVcsFor(path); if (vcs != null && VCS_NAME.equals(vcs.getName())) { try { client.doAddToChangelist(new File[] {path.getIOFile()}, SVNDepth.EMPTY, name, null); } catch (SVNException e) { // left in default list } } } }
private void baseRevisionsOfDvcsIntoContext( List<Change> textChanges, CommitContext commitContext) { ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); if (vcsManager.dvcsUsedInProject() && VcsConfiguration.getInstance(myProject).INCLUDE_TEXT_INTO_SHELF) { final Set<Change> big = SelectFilesToAddTextsToPatchPanel.getBig(textChanges); final ArrayList<FilePath> toKeep = new ArrayList<FilePath>(); for (Change change : textChanges) { if (change.getBeforeRevision() == null || change.getAfterRevision() == null) continue; if (big.contains(change)) continue; FilePath filePath = ChangesUtil.getFilePath(change); final AbstractVcs vcs = vcsManager.getVcsFor(filePath); if (vcs != null && VcsType.distibuted.equals(vcs.getType())) { toKeep.add(filePath); } } commitContext.putUserData(BaseRevisionTextPatchEP.ourPutBaseRevisionTextKey, true); commitContext.putUserData(BaseRevisionTextPatchEP.ourBaseRevisionPaths, toKeep); } }
public Map<VirtualFile, RepositoryLocation> getRoots() { myContentRoots = myPlManager.getRootsUnderVcs(myVcs); List<VirtualFile> roots = new ArrayList<>(); final List<VcsDirectoryMapping> mappings = myPlManager.getDirectoryMappings(myVcs); for (VcsDirectoryMapping mapping : mappings) { if (mapping.isDefaultMapping()) { if (myVcs.equals(myPlManager.getVcsFor(myProject.getBaseDir()))) { roots.add(myProject.getBaseDir()); } } else { VirtualFile newFile = LocalFileSystem.getInstance().findFileByPath(mapping.getDirectory()); if (newFile == null) { newFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(mapping.getDirectory()); } if (newFile != null) { roots.add(newFile); } else { LOG.info("Can not file virtual file for root: " + mapping.getDirectory()); } } } ContainerUtil.addAll(roots, myContentRoots); final Map<VirtualFile, RepositoryLocation> result = new HashMap<>(); for (Iterator<VirtualFile> iterator = roots.iterator(); iterator.hasNext(); ) { final VirtualFile vf = iterator.next(); final RepositoryLocation location = myLocationCache.getLocation(myVcs, VcsUtil.getFilePath(vf), false); if (location != null) { result.put(vf, location); } else { iterator.remove(); } } roots = myVcs.filterUniqueRoots(roots, IntoSelfVirtualFileConvertor.getInstance()); result.keySet().retainAll(roots); logRoots(roots); return result; }
private static void doAnnotate(final Editor editor, final Project project) { if (project == null) { return; } final VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument()); if (file == null) { return; } final ProjectLevelVcsManager plVcsManager = ProjectLevelVcsManager.getInstance(project); AbstractVcs vcs = plVcsManager.getVcsFor(file); if (vcs == null) { return; } final AnnotationProvider annotationProvider = vcs.getAnnotationProvider(); if (annotationProvider == null) { return; } final Ref<FileAnnotation> fileAnnotationRef = new Ref<FileAnnotation>(); final Ref<VcsException> exceptionRef = new Ref<VcsException>(); final BackgroundableActionEnabledHandler handler = ((ProjectLevelVcsManagerImpl) plVcsManager) .getBackgroundableActionHandler(VcsBackgroundableActions.ANNOTATE); handler.register(file.getPath()); ProgressManager.getInstance() .run( new Task.Backgroundable( project, VcsBundle.message("retrieving.annotations"), true, BackgroundFromStartOption.getInstance()) { public void run(@NotNull ProgressIndicator indicator) { try { fileAnnotationRef.set(annotationProvider.annotate(file)); } catch (VcsException e) { exceptionRef.set(e); } } @Override public void onCancel() { onSuccess(); } @Override public void onSuccess() { handler.completed(file.getPath()); if (!exceptionRef.isNull()) { AbstractVcsHelper.getInstance(project) .showErrors( Arrays.asList(exceptionRef.get()), VcsBundle.message("message.title.annotate")); } if (fileAnnotationRef.isNull()) { return; } doAnnotate(editor, project, fileAnnotationRef.get()); } }); }