com.intellij.openapi.vcs.AbstractVcs Java Examples
The following examples show how to use
com.intellij.openapi.vcs.AbstractVcs.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RollbackUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Finds the most appropriate name for the "Rollback" operation for the given VCSs. * That is: iterates through the all {@link RollbackEnvironment#getRollbackOperationName() RollbackEnvironments} and picks * the operation name if it is equal to all given VCSs. * Otherwise picks the {@link DefaultRollbackEnvironment#ROLLBACK_OPERATION_NAME default name}. * @param vcses affected VCSs. * @return name for the "rollback" operation to be used in the UI. */ @Nonnull public static String getRollbackOperationName(@Nonnull Collection<AbstractVcs> vcses) { String operationName = null; for (AbstractVcs vcs : vcses) { final RollbackEnvironment rollbackEnvironment = vcs.getRollbackEnvironment(); if (rollbackEnvironment != null) { if (operationName == null) { operationName = rollbackEnvironment.getRollbackOperationName(); } else if (!operationName.equals(rollbackEnvironment.getRollbackOperationName())) { // if there are different names, use default return DefaultRollbackEnvironment.ROLLBACK_OPERATION_NAME; } } } return operationName != null ? operationName : DefaultRollbackEnvironment.ROLLBACK_OPERATION_NAME; }
Example #2
Source File: VcsRepositoryManager.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private Map<VirtualFile, Repository> findNewRoots(@Nonnull Set<VirtualFile> knownRoots) { Map<VirtualFile, Repository> newRootsMap = ContainerUtil.newHashMap(); for (VcsRoot root : myVcsManager.getAllVcsRoots()) { VirtualFile rootPath = root.getPath(); if (rootPath != null && !knownRoots.contains(rootPath)) { AbstractVcs vcs = root.getVcs(); VcsRepositoryCreator repositoryCreator = getRepositoryCreator(vcs); if (repositoryCreator == null) continue; Repository repository = repositoryCreator.createRepositoryIfValid(rootPath); if (repository != null) { newRootsMap.put(rootPath, repository); } } } return newRootsMap; }
Example #3
Source File: VcsDirtyScopeManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private MultiMap<AbstractVcs, FilePath> getEverythingDirtyRoots() { MultiMap<AbstractVcs, FilePath> dirtyRoots = MultiMap.createSet(); dirtyRoots.putAllValues(groupByVcs(toFilePaths(DefaultVcsRootPolicy.getInstance(myProject).getDirtyRoots()))); List<VcsDirectoryMapping> mappings = myVcsManager.getDirectoryMappings(); for (VcsDirectoryMapping mapping : mappings) { if (!mapping.isDefaultMapping() && mapping.getVcs() != null) { AbstractVcs vcs = myVcsManager.findVcsByName(mapping.getVcs()); if (vcs != null) { dirtyRoots.putValue(vcs, VcsUtil.getFilePath(mapping.getDirectory(), true)); } } } return dirtyRoots; }
Example #4
Source File: AnnotateCurrentRevisionAction.java From consulo with Apache License 2.0 | 6 votes |
public AnnotateCurrentRevisionAction(@Nonnull FileAnnotation annotation, @Nonnull AbstractVcs vcs) { super("Annotate Revision", "Annotate selected revision in new tab", AllIcons.Actions.Annotate, annotation, vcs); List<VcsFileRevision> revisions = annotation.getRevisions(); if (revisions == null) { myRevisions = null; return; } Map<VcsRevisionNumber, VcsFileRevision> map = new HashMap<VcsRevisionNumber, VcsFileRevision>(); for (VcsFileRevision revision : revisions) { map.put(revision.getRevisionNumber(), revision); } myRevisions = new ArrayList<VcsFileRevision>(annotation.getLineCount()); for (int i = 0; i < annotation.getLineCount(); i++) { myRevisions.add(map.get(annotation.getLineRevisionNumber(i))); } }
Example #5
Source File: PushController.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private <R extends Repository, S extends PushSource, T extends PushTarget> List<PushSupport<R, S, T>> getAffectedSupports() { Collection<Repository> repositories = myGlobalRepositoryManager.getRepositories(); Collection<AbstractVcs> vcss = ContainerUtil.map2Set(repositories, new Function<Repository, AbstractVcs>() { @Override public AbstractVcs fun(@Nonnull Repository repository) { return repository.getVcs(); } }); return ContainerUtil.map(vcss, new Function<AbstractVcs, PushSupport<R, S, T>>() { @Override public PushSupport<R, S, T> fun(AbstractVcs vcs) { //noinspection unchecked return DvcsUtil.getPushSupport(vcs); } }); }
Example #6
Source File: ReviewItem.java From Crucible4IDEA with MIT License | 6 votes |
@NotNull public List<CommittedChangeList> loadChangeLists(@NotNull Project project, @NotNull AbstractVcs vcsFor, @NotNull Set<String> loadedRevisions, FilePath path) throws VcsException { final Set<String> revisions = getRevisions(); List<CommittedChangeList> changeLists = new ArrayList<CommittedChangeList>(); for (String revision : revisions) { if (!loadedRevisions.contains(revision)) { final VcsRevisionNumber revisionNumber = vcsFor.parseRevisionNumber(revision); if (revisionNumber != null) { final CommittedChangeList changeList = VcsUtils.loadRevisions(project, revisionNumber, path); if (changeList != null) changeLists.add(changeList); } loadedRevisions.add(revision); } } return changeLists; }
Example #7
Source File: RemoteRevisionsNumbersCache.java From consulo with Apache License 2.0 | 6 votes |
public void plus(final Pair<String, AbstractVcs> pair) { // does not support if (pair.getSecond().getDiffProvider() == null) return; final String key = pair.getFirst(); final AbstractVcs newVcs = pair.getSecond(); final VirtualFile root = getRootForPath(key); if (root == null) return; final VcsRoot vcsRoot = new VcsRoot(newVcs, root); synchronized (myLock) { final Pair<VcsRoot, VcsRevisionNumber> value = myData.get(key); if (value == null) { final LazyRefreshingSelfQueue<String> queue = getQueue(vcsRoot); myData.put(key, Pair.create(vcsRoot, NOT_LOADED)); queue.addRequest(key); } else if (! value.getFirst().equals(vcsRoot)) { switchVcs(value.getFirst(), vcsRoot, key); } } }
Example #8
Source File: VcsRootDetectorImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private Set<VcsRoot> scanForRootsInsideDir(@Nonnull final VirtualFile dir, final int depth) { final Set<VcsRoot> roots = new HashSet<VcsRoot>(); if (depth > MAXIMUM_SCAN_DEPTH) { // performance optimization via limitation: don't scan deep though the whole VFS, 2 levels under a content root is enough return roots; } if (myProject.isDisposed() || !dir.isDirectory()) { return roots; } List<AbstractVcs> vcsList = getVcsListFor(dir); for (AbstractVcs vcs : vcsList) { roots.add(new VcsRoot(vcs, dir)); } for (VirtualFile child : dir.getChildren()) { roots.addAll(scanForRootsInsideDir(child, depth + 1)); } return roots; }
Example #9
Source File: VcsRootDetectorImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private List<VcsRoot> scanForSingleRootAboveDir(@Nonnull final VirtualFile dir) { List<VcsRoot> roots = new ArrayList<VcsRoot>(); if (myProject.isDisposed()) { return roots; } VirtualFile par = dir.getParent(); while (par != null) { List<AbstractVcs> vcsList = getVcsListFor(par); for (AbstractVcs vcs : vcsList) { roots.add(new VcsRoot(vcs, par)); } if (!roots.isEmpty()) { return roots; } par = par.getParent(); } return roots; }
Example #10
Source File: VcsUtils.java From Crucible4IDEA with MIT License | 6 votes |
@Nullable public static CommittedChangeList loadRevisions(@NotNull final Project project, final VcsRevisionNumber number, final FilePath filePath) { final CommittedChangeList[] list = new CommittedChangeList[1]; final ThrowableRunnable<VcsException> runnable = () -> { final AbstractVcs vcs = VcsUtil.getVcsFor(project, filePath); if (vcs == null) { return; } list[0] = vcs.loadRevisions(filePath.getVirtualFile(), number); }; final boolean success = VcsSynchronousProgressWrapper.wrap(runnable, project, "Load Revision Contents"); return success ? list[0] : null; }
Example #11
Source File: ActionInfo.java From consulo with Apache License 2.0 | 6 votes |
public UpdateOrStatusOptionsDialog createOptionsDialog(final Project project, LinkedHashMap<Configurable, AbstractVcs> envToConfMap, final String scopeName) { return new UpdateOrStatusOptionsDialog(project, envToConfMap) { protected String getRealTitle() { return VcsBundle.message("action.display.name.check.scope.status", scopeName); } @Override protected String getActionNameForDimensions() { return "status"; } protected boolean isToBeShown() { return ProjectLevelVcsManagerEx.getInstanceEx(project).getOptions(VcsConfiguration.StandardOption.STATUS).getValue(); } protected void setToBeShown(boolean value, boolean onOk) { if (onOk) { ProjectLevelVcsManagerEx.getInstanceEx(project).getOptions(VcsConfiguration.StandardOption.STATUS).setValue(value); } } }; }
Example #12
Source File: RemoteRevisionsNumbersCache.java From consulo with Apache License 2.0 | 6 votes |
public Boolean compute() { final AbstractVcs vcs = myVcsRoot.getVcs(); // won't be called in parallel for same vcs -> just synchronized map is ok final String vcsName = vcs.getName(); LOG.debug("should update for: " + vcsName + " root: " + myVcsRoot.getPath().getPath()); final VcsRevisionNumber latestNew = vcs.getDiffProvider().getLatestCommittedRevision(myVcsRoot.getPath()); // TODO: Why vcsName is used as key and not myVcsRoot.getKey()??? // TODO: This seems to be invalid logic as we get latest revision for vcs root final VcsRevisionNumber latestKnown = myLatestRevisionsMap.get(vcsName); // not known if (latestNew == null) return true; if ((latestKnown == null) || (latestNew.compareTo(latestKnown) != 0)) { myLatestRevisionsMap.put(vcsName, latestNew); return true; } return false; }
Example #13
Source File: ActionInfo.java From consulo with Apache License 2.0 | 6 votes |
public UpdateOrStatusOptionsDialog createOptionsDialog(final Project project, LinkedHashMap<Configurable, AbstractVcs> envToConfMap, final String scopeName) { return new UpdateOrStatusOptionsDialog(project, envToConfMap) { protected String getRealTitle() { return VcsBundle.message("action.display.name.integrate.scope", scopeName); } @Override protected String getActionNameForDimensions() { return "integrate"; } protected boolean canBeHidden() { return false; } protected boolean isToBeShown() { return true; } protected void setToBeShown(boolean value, boolean onOk) { } }; }
Example #14
Source File: VcsQuickListPopupAction.java From consulo with Apache License 2.0 | 6 votes |
private Pair<SupportedVCS, AbstractVcs> getActiveVCS(@Nonnull final Project project, @javax.annotation.Nullable final DataContext dataContext) { final AbstractVcs[] activeVcss = getActiveVCSs(project); if (activeVcss.length == 0) { // no vcs return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.NOT_IN_VCS, null); } else if (activeVcss.length == 1) { // get by name return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, activeVcss[0]); } // by current file final VirtualFile file = dataContext != null ? dataContext.getData(PlatformDataKeys.VIRTUAL_FILE) : null; if (file != null) { final AbstractVcs vscForFile = ProjectLevelVcsManager.getInstance(project).getVcsFor(file); if (vscForFile != null) { return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, vscForFile); } } return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, null); }
Example #15
Source File: VcsDirtyScopeManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private MultiMap<AbstractVcs, FilePath> groupByVcs(@Nullable final Collection<FilePath> from) { if (from == null) return MultiMap.empty(); MultiMap<AbstractVcs, FilePath> map = MultiMap.createSet(); for (FilePath path : from) { AbstractVcs vcs = myGuess.getVcsForDirty(path); if (vcs != null) { map.putValue(vcs, path); } } return map; }
Example #16
Source File: TabbedShowHistoryAction.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void actionPerformed(@Nonnull VcsContext context) { Project project = context.getProject(); Pair<FilePath, VirtualFile> pair = getPathAndParentFile(context); FilePath path = assertNotNull(pair.first); VirtualFile fileOrParent = assertNotNull(pair.second); AbstractVcs vcs = assertNotNull(ChangesUtil.getVcsForFile(fileOrParent, project)); VcsHistoryProvider provider = assertNotNull(vcs.getVcsHistoryProvider()); AbstractVcsHelper.getInstance(project).showFileHistory(provider, vcs.getAnnotationProvider(), path, null, vcs); }
Example #17
Source File: VcsManagerConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private void addListenerToGeneralPanel() { myMappings.addVcsListener(new ModuleVcsListener() { @Override public void activeVcsSetChanged(Collection<AbstractVcs> activeVcses) { myGeneralPanel.updateAvailableOptions(activeVcses); } }); }
Example #18
Source File: AnnotateToggleAction.java From consulo with Apache License 2.0 | 5 votes |
public static void doAnnotate(@Nonnull final Editor editor, @Nonnull final Project project, @Nullable final VirtualFile currentFile, @Nonnull final FileAnnotation fileAnnotation, @Nonnull final AbstractVcs vcs) { UpToDateLineNumberProvider upToDateLineNumberProvider = new UpToDateLineNumberProviderImpl(editor.getDocument(), project); doAnnotate(editor, project, currentFile, fileAnnotation, vcs, upToDateLineNumberProvider); }
Example #19
Source File: VcsRootDetectorImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private List<AbstractVcs> getVcsListFor(@Nonnull VirtualFile dir) { List<AbstractVcs> vcsList = new ArrayList<AbstractVcs>(); for (VcsRootChecker checker : myCheckers) { if (checker.isRoot(dir.getPath())) { vcsList.add(myVcsManager.findVcsByName(checker.getSupportedVcs().getName())); } } return vcsList; }
Example #20
Source File: AllVcses.java From consulo with Apache License 2.0 | 5 votes |
private void registerVcs(final AbstractVcs vcs) { try { vcs.loadSettings(); vcs.doStart(); } catch (VcsException e) { LOG.debug(e); } vcs.getProvidedStatuses(); }
Example #21
Source File: VcsHandleTypeFactory.java From consulo with Apache License 2.0 | 5 votes |
@javax.annotation.Nullable public HandleType createHandleType(final VirtualFile file) { if (! myProject.isInitialized()) return null; AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file); if (vcs != null) { boolean fileExistsInVcs = vcs.fileExistsInVcs(new FilePathImpl(file)); if (fileExistsInVcs && vcs.getEditFileProvider() != null) { return new VcsHandleType(vcs); } } return null; }
Example #22
Source File: ModuleVcsDetector.java From consulo with Apache License 2.0 | 5 votes |
private void autoDetectModuleVcsMapping(final Module module) { boolean mappingsUpdated = false; final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots(); for(VirtualFile file: files) { AbstractVcs vcs = myVcsManager.findVersioningVcs(file); if (vcs != null && vcs != myVcsManager.getVcsFor(file)) { myVcsManager.setAutoDirectoryMapping(file.getPath(), vcs.getName()); mappingsUpdated = true; } } if (mappingsUpdated) { myVcsManager.cleanupMappings(); } }
Example #23
Source File: RecursiveFileHolder.java From consulo with Apache License 2.0 | 5 votes |
protected boolean isFileDirty(final VcsDirtyScope scope, final VirtualFile file) { if (!file.isValid()) return true; final AbstractVcs[] vcsArr = new AbstractVcs[1]; if (scope.belongsTo(VcsUtil.getFilePath(file), vcs -> vcsArr[0] = vcs)) { return true; } return vcsArr[0] == null; }
Example #24
Source File: AnnotateToggleAction.java From consulo with Apache License 2.0 | 5 votes |
public MyEditorNotificationPanel(@Nonnull Editor editor, @Nonnull AbstractVcs vcs, @Nonnull Runnable doShowAnnotations) { super(LightColors.RED); myEditor = editor; myShowAnnotations = doShowAnnotations; setText(VcsBundle.message("annotation.wrong.line.number.notification.text", vcs.getDisplayName())); createActionLabel("Display anyway", () -> { showAnnotations(); }); createActionLabel("Hide", () -> { hideNotification(); }).setToolTipText("Hide this notification"); }
Example #25
Source File: AbstractRepositoryManager.java From consulo with Apache License 2.0 | 5 votes |
protected AbstractRepositoryManager(@Nonnull VcsRepositoryManager globalRepositoryManager, @Nonnull AbstractVcs vcs, @Nonnull String repoDirName) { myGlobalRepositoryManager = globalRepositoryManager; myVcs = vcs; myRepoDirName = repoDirName; }
Example #26
Source File: TfvcIntegrationEnabler.java From azure-devops-intellij with MIT License | 5 votes |
@SuppressWarnings("unchecked") @Override public void enable(@NotNull Collection vcsRoots) { // This override does the same as base method, but tries to determine a workspace directory instead of using // project.getBaseDir(). Collection<VcsRoot> typedRoots = (Collection<VcsRoot>)vcsRoots; Collection<VirtualFile> existingRoots = typedRoots.stream().filter(root -> { AbstractVcs vcs = root.getVcs(); return vcs != null && vcs.getName().equals(myVcs.getName()); }).map(VcsRoot::getPath).collect(toList()); if (!existingRoots.isEmpty()) { super.enable(vcsRoots); return; } String basePath = myProject.getBasePath(); if (basePath == null) { ourLogger.warn("Project base path is null"); return; } Path workspacePath = determineWorkspaceDirectory(Paths.get(basePath)); VirtualFile workspaceFile = ObjectUtils.notNull( LocalFileSystem.getInstance().findFileByIoFile(workspacePath.toFile())); if (initOrNotifyError(workspaceFile)) addVcsRoot(workspaceFile); }
Example #27
Source File: VcsDirtyScopeImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean belongsTo(final FilePath path, final Consumer<AbstractVcs> vcsConsumer) { if (myProject.isDisposed()) return false; final VcsRoot rootObject = myVcsManager.getVcsRootObjectFor(path); if (vcsConsumer != null && rootObject != null) { vcsConsumer.consume(rootObject.getVcs()); } if (rootObject == null || rootObject.getVcs() != myVcs) { return false; } final VirtualFile vcsRoot = rootObject.getPath(); if (vcsRoot != null) { for (VirtualFile contentRoot : myAffectedContentRoots) { // since we don't know exact dirty mechanics, maybe we have 3 nested mappings like: // /root -> vcs1, /root/child -> vcs2, /root/child/inner -> vcs1, and we have file /root/child/inner/file, // mapping is detected as vcs1 with root /root/child/inner, but we could possibly have in scope // "affected root" -> /root with scope = /root recursively if (VfsUtilCore.isAncestor(contentRoot, vcsRoot, false)) { THashSet<FilePath> dirsByRoot = myDirtyDirectoriesRecursively.get(contentRoot); if (dirsByRoot != null) { for (FilePath filePath : dirsByRoot) { if (path.isUnder(filePath, false)) return true; } } } } } if (!myDirtyFiles.isEmpty()) { FilePath parent = path.getParentPath(); return isInDirtyFiles(path) || isInDirtyFiles(parent); } return false; }
Example #28
Source File: CheckinHandlersManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public List<BaseCheckinHandlerFactory> getRegisteredCheckinHandlerFactories(AbstractVcs[] allActiveVcss) { final ArrayList<BaseCheckinHandlerFactory> list = new ArrayList<>(myRegisteredBeforeCheckinHandlers.size() + allActiveVcss.length); list.addAll(myRegisteredBeforeCheckinHandlers); for (AbstractVcs vcs : allActiveVcss) { final Collection<VcsCheckinHandlerFactory> factories = myVcsMap.get(vcs.getKeyInstanceMethod()); if (!factories.isEmpty()) { list.addAll(factories); } } return list; }
Example #29
Source File: AllVcses.java From consulo with Apache License 2.0 | 5 votes |
@Override public void dispose() { synchronized (myLock) { for (AbstractVcs vcs : myVcses.values()) { unregisterVcs(vcs); } } }
Example #30
Source File: AbstractMissingFilesAction.java From consulo with Apache License 2.0 | 5 votes |
public void actionPerformed(AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); final List<FilePath> files = e.getData(ChangesListView.MISSING_FILES_DATA_KEY); if (files == null) return; final ProgressManager progressManager = ProgressManager.getInstance(); final Runnable action = new Runnable() { public void run() { final List<VcsException> allExceptions = new ArrayList<VcsException>(); ChangesUtil.processFilePathsByVcs(project, files, new ChangesUtil.PerVcsProcessor<FilePath>() { public void process(final AbstractVcs vcs, final List<FilePath> items) { final List<VcsException> exceptions = processFiles(vcs, files); if (exceptions != null) { allExceptions.addAll(exceptions); } } }); for (FilePath file : files) { VcsDirtyScopeManager.getInstance(project).fileDirty(file); } ChangesViewManager.getInstance(project).scheduleRefresh(); if (allExceptions.size() > 0) { AbstractVcsHelper.getInstance(project).showErrors(allExceptions, "VCS Errors"); } } }; if (synchronously()) { action.run(); } else { progressManager.runProcessWithProgressSynchronously(action, getName(), true, project); } }