Java Code Examples for com.intellij.openapi.vcs.history.VcsRevisionNumber#asString()
The following examples show how to use
com.intellij.openapi.vcs.history.VcsRevisionNumber#asString() .
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: ShowAllAffectedGenericAction.java From consulo with Apache License 2.0 | 6 votes |
public static CommittedChangeList getRemoteList(final AbstractVcs vcs, final VcsRevisionNumber revision, final VirtualFile nonLocal) throws VcsException { final CommittedChangesProvider provider = vcs.getCommittedChangesProvider(); final RepositoryLocation local = provider.getForNonLocal(nonLocal); if (local != null) { final String number = revision.asString(); final ChangeBrowserSettings settings = provider.createDefaultSettings(); final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue()); if (changes != null) { for (CommittedChangeList change : changes) { if (number.equals(String.valueOf(change.getNumber()))) { return change; } } } } return null; }
Example 2
Source File: CopyRevisionNumberFromAnnotateAction.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { if (myLineNumber < 0) return; final VcsRevisionNumber revisionNumber = myAnnotation.getLineRevisionNumber(myLineNumber); if (revisionNumber != null) { final String revision = revisionNumber.asString(); CopyPasteManager.getInstance().setContents(new TextTransferable(revision)); } }
Example 3
Source File: P4CommittedChangesProvider.java From p4ic4idea with Apache License 2.0 | 4 votes |
/** * Called by IDE in a Worker Thread. * * @param file file * @param number revision * @return required list and path of the target file in that revision (changes when move/rename) */ @Nullable @Override public Pair<P4CommittedChangelist, FilePath> getOneList(VirtualFile file, VcsRevisionNumber number) { if (LOG.isDebugEnabled()) { LOG.debug("Getting one list for " + file + " " + number); } FilePath fp = VcsUtil.getFilePath(file); if (fp == null) { return null; } ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); if (registry == null) { return Pair.create(null, fp); } ClientConfigRoot clientConfig = registry.getClientFor(file); if (clientConfig == null) { return Pair.create(null, fp); } String revision; if (number != null) { revision = number.asString(); if (revision == null || revision.isEmpty()) { revision = "#head"; } else if (!(revision.charAt(0) == '@' || revision.charAt(0) == '#')) { revision = '#' + revision; } } else { revision = "#head"; } if (LOG.isDebugEnabled()) { LOG.debug("Getting changelist for " + file + " " + revision); } // FIXME pull the revision from the server. This is in a worker thread, so do a blocking wait. LOG.warn("FIXME pull the revision from the server. This is in a worker thread, so do a blocking wait."); return Pair.create(null, fp); }
Example 4
Source File: ShowAllAffectedGenericAction.java From consulo with Apache License 2.0 | 4 votes |
public static void showSubmittedFiles(final Project project, final VcsRevisionNumber revision, final VirtualFile virtualFile, final VcsKey vcsKey, final RepositoryLocation location, final boolean isNonLocal) { final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName()); if (vcs == null) return; if (isNonLocal && ! canPresentNonLocal(project, vcsKey, virtualFile)) return; final String title = VcsBundle.message("paths.affected.in.revision", revision instanceof ShortVcsRevisionNumber ? ((ShortVcsRevisionNumber) revision).toShortString() : revision.asString()); final CommittedChangeList[] list = new CommittedChangeList[1]; final VcsException[] exc = new VcsException[1]; Task.Backgroundable task = new Task.Backgroundable(project, title, true, BackgroundFromStartOption.getInstance()) { @Override public void run(@Nonnull ProgressIndicator indicator) { try { final CommittedChangesProvider provider = vcs.getCommittedChangesProvider(); if (!isNonLocal) { final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision); if (pair != null) { list[0] = pair.getFirst(); } } else { if (location != null) { final ChangeBrowserSettings settings = provider.createDefaultSettings(); settings.USE_CHANGE_BEFORE_FILTER = true; settings.CHANGE_BEFORE = revision.asString(); final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1); if (changes != null && changes.size() == 1) { list[0] = changes.get(0); } return; } else { list[0] = getRemoteList(vcs, revision, virtualFile); /*final RepositoryLocation local = provider.getForNonLocal(virtualFile); if (local != null) { final String number = revision.asString(); final ChangeBrowserSettings settings = provider.createDefaultSettings(); final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, local, provider.getUnlimitedCountValue()); if (changes != null) { for (CommittedChangeList change : changes) { if (number.equals(String.valueOf(change.getNumber()))) { list[0] = change; } } } } */ } } } catch (VcsException e) { exc[0] = e; } } @RequiredUIAccess @Override public void onSuccess() { final AbstractVcsHelper instance = AbstractVcsHelper.getInstance(project); if (exc[0] != null) { instance.showError(exc[0], failedText(virtualFile, revision)); } else if (list[0] == null) { Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle()); } else { instance.showChangesListBrowser(list[0], virtualFile, title); } } }; ProgressManager.getInstance().run(task); }
Example 5
Source File: ShowAllAffectedGenericAction.java From consulo with Apache License 2.0 | 4 votes |
private static String failedText(VirtualFile virtualFile, VcsRevisionNumber revision) { return "Show all affected files for " + virtualFile.getPath() + " at " + revision.asString() + " failed"; }