use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class AbstractVcsHelperImpl method getRemoteList.
@Nullable
public static CommittedChangeList getRemoteList(@NotNull AbstractVcs vcs, @NotNull VcsRevisionNumber revision, @NotNull 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;
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class AbstractVcsHelperImpl method loadAndShowCommittedChangesDetails.
@Override
public void loadAndShowCommittedChangesDetails(@NotNull final Project project, @NotNull final VcsRevisionNumber revision, @NotNull final VirtualFile virtualFile, @NotNull VcsKey vcsKey, @Nullable final RepositoryLocation location, final boolean isNonLocal) {
final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
if (vcs == null)
return;
final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
if (provider == null)
return;
if (isNonLocal && provider.getForNonLocal(virtualFile) == null)
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 FilePath[] targetPath = new FilePath[1];
final VcsException[] exc = new VcsException[1];
final BackgroundableActionLock lock = BackgroundableActionLock.getLock(project, VcsBackgroundableActions.COMMITTED_CHANGES_DETAILS, revision, virtualFile.getPath());
if (lock.isLocked())
return;
lock.lock();
Task.Backgroundable task = new Task.Backgroundable(project, title, true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
if (!isNonLocal) {
final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
if (pair != null) {
list[0] = pair.getFirst();
targetPath[0] = pair.getSecond();
}
} 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);
}
} else {
list[0] = getRemoteList(vcs, revision, virtualFile);
}
}
} catch (VcsException e) {
exc[0] = e;
}
}
@Override
public void onCancel() {
lock.unlock();
}
@Override
public void onSuccess() {
lock.unlock();
if (exc[0] != null) {
showError(exc[0], failedText(virtualFile, revision));
} else if (list[0] == null) {
Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
} else {
VirtualFile navigateToFile = targetPath[0] != null ? new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) : virtualFile;
showChangesListBrowser(list[0], navigateToFile, title);
}
}
};
// we can's use runProcessWithProgressAsynchronously(task) because then ModalityState.NON_MODAL would be used
CoreProgressManager progressManager = (CoreProgressManager) ProgressManager.getInstance();
progressManager.runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task), null, ModalityState.current());
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class UpdateInfoTree method createCenterPanel.
protected JComponent createCenterPanel() {
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTree);
scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.LEFT));
myCenterPanel.add(CARD_STATUS, scrollPane);
myTreeBrowser = new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList());
Disposer.register(this, myTreeBrowser);
myTreeBrowser.setHelpId(getHelpId());
myCenterPanel.add(CARD_CHANGES, myTreeBrowser);
return myCenterPanel;
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class CommittedChangesBrowser method updateBySelectionChange.
private void updateBySelectionChange() {
final int idx = myChangeListsView.getSelectionModel().getLeadSelectionIndex();
final List<CommittedChangeList> items = myTableModel.getItems();
CommittedChangeList list = (idx >= 0 && idx < items.size()) ? items.get(idx) : null;
if (list != mySelectedChangeList) {
mySelectedChangeList = list;
myChangesView.setChangesToDisplay(list != null ? new ArrayList<>(list.getChanges()) : Collections.<Change>emptyList());
myCommitMessageArea.setText(list != null ? formatText(list) : "");
myCommitMessageArea.select(0, 0);
}
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class CommittedChangesCache method initCache.
private List<CommittedChangeList> initCache(final ChangesCacheFile cacheFile) throws VcsException, IOException {
debug("Initializing cache for " + cacheFile.getLocation());
final CachingCommittedChangesProvider provider = cacheFile.getProvider();
final RepositoryLocation location = cacheFile.getLocation();
final ChangeBrowserSettings settings = provider.createDefaultSettings();
int maxCount = 0;
if (isMaxCountSupportedForProject()) {
maxCount = myState.getInitialCount();
} else {
settings.USE_DATE_AFTER_FILTER = true;
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DAY_OF_YEAR, -myState.getInitialDays());
settings.setDateAfter(calendar.getTime());
}
//noinspection unchecked
final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, maxCount);
// when initially initializing cache, assume all changelists are locally available
// this sorts changes in chronological order
writeChangesInReadAction(cacheFile, changes);
if (maxCount > 0 && changes.size() < myState.getInitialCount()) {
cacheFile.setHaveCompleteHistory(true);
}
if (changes.size() > 0) {
fireChangesLoaded(location, changes);
}
return changes;
}
Aggregations