use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class GitDiffProvider method createFileContent.
/**
* {@inheritDoc}
*/
@Nullable
public ContentRevision createFileContent(VcsRevisionNumber revisionNumber, VirtualFile selectedFile) {
if (selectedFile.isDirectory()) {
return null;
}
final String path = selectedFile.getPath();
if (GitUtil.gitRootOrNull(selectedFile) == null) {
return null;
}
// faster, if there were no renames
FilePath filePath = VcsUtil.getFilePath(path);
try {
final CommittedChangesProvider committedChangesProvider = GitVcs.getInstance(myProject).getCommittedChangesProvider();
final Pair<CommittedChangeList, FilePath> pair = committedChangesProvider.getOneList(selectedFile, revisionNumber);
if (pair != null) {
return GitContentRevision.createRevision(pair.getSecond(), revisionNumber, myProject, selectedFile.getCharset());
}
} catch (VcsException e) {
GitVcs.getInstance(myProject).showErrors(Collections.singletonList(e), GitBundle.message("diff.find.error", path));
}
try {
for (VcsFileRevision f : GitHistoryUtils.history(myProject, filePath)) {
GitFileRevision gitRevision = (GitFileRevision) f;
if (f.getRevisionNumber().equals(revisionNumber)) {
return GitContentRevision.createRevision(gitRevision.getPath(), revisionNumber, myProject, selectedFile.getCharset());
}
}
GitContentRevision candidate = (GitContentRevision) GitContentRevision.createRevision(filePath, revisionNumber, myProject, selectedFile.getCharset());
try {
candidate.getContent();
return candidate;
} catch (VcsException e) {
// file does not exists
}
} catch (VcsException e) {
GitVcs.getInstance(myProject).showErrors(Collections.singletonList(e), GitBundle.message("diff.find.error", path));
}
return null;
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class ChangeListDetailsAction method actionPerformed.
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
Project project = e.getRequiredData(PROJECT);
ChangeList[] changeLists = e.getRequiredData(CHANGE_LISTS);
showDetailsPopup(project, (CommittedChangeList) changeLists[0]);
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class ChangesBrowserDialog method initDialog.
private void initDialog(final Project project, final CommittedChangesTableModel changes, final Mode mode) {
myProject = project;
myChanges = changes;
myMode = mode;
setTitle(VcsBundle.message("dialog.title.changes.browser"));
setCancelButtonText(CommonBundle.getCloseButtonText());
final ModalityState currentState = ModalityState.current();
if ((mode != Mode.Choose) && (ModalityState.NON_MODAL.equals(currentState))) {
setModal(false);
}
myAppender = new AsynchConsumer<List<CommittedChangeList>>() {
public void finished() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (ChangesBrowserDialog.this.isShowing()) {
myCommittedChangesBrowser.stopLoading();
}
}
});
}
public void consume(final List<CommittedChangeList> committedChangeLists) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
if (ChangesBrowserDialog.this.isShowing()) {
final boolean selectFirst = (myChanges.getRowCount() == 0) && (!committedChangeLists.isEmpty());
myChanges.addRows(committedChangeLists);
if (selectFirst) {
myCommittedChangesBrowser.selectFirstIfAny();
}
}
}
});
}
};
init();
if (myInitRunnable != null) {
new AdjustComponentWhenShown() {
@Override
protected boolean init() {
myInitRunnable.consume(ChangesBrowserDialog.this);
return true;
}
}.install(myCommittedChangesBrowser);
}
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class ChangesCacheFile method readChangesInterval.
private List<CommittedChangeList> readChangesInterval(final long indexOffset, final int number) throws IOException {
openStreams();
try {
IndexEntry[] entries = readIndexEntriesByOffset(indexOffset, number);
if (entries.length == 0) {
return Collections.emptyList();
}
final List<CommittedChangeList> result = new ArrayList<>();
for (IndexEntry entry : entries) {
final CommittedChangeList changeList = loadChangeListAt(entry.offset);
result.add(changeList);
}
return result;
} finally {
closeStreams();
}
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class ChangesCacheFile method writeChanges.
public List<CommittedChangeList> writeChanges(final List<CommittedChangeList> changes, @Nullable final List<Boolean> present) throws IOException {
assert present == null || present.size() == changes.size();
List<CommittedChangeList> result = new ArrayList<>(changes.size());
boolean wasEmpty = isEmpty();
openStreams();
try {
if (wasEmpty) {
myHeaderLoaded = true;
writeHeader();
}
myStream.seek(myStream.length());
IndexEntry[] entries = readLastIndexEntries(0, changes.size());
final Iterator<Boolean> iterator = present == null ? null : present.iterator();
for (CommittedChangeList list : changes) {
boolean duplicate = false;
for (IndexEntry entry : entries) {
if (list.getCommitDate().getTime() == entry.date && list.getNumber() == entry.number) {
duplicate = true;
break;
}
}
if (duplicate) {
debug("Skipping duplicate changelist " + list.getNumber());
continue;
}
debug("Writing incoming changelist " + list.getNumber());
result.add(list);
long position = myStream.getFilePointer();
//noinspection unchecked
myChangesProvider.writeChangeList(myStream, list);
updateCachedRange(list);
writeIndexEntry(list.getNumber(), list.getCommitDate().getTime(), position, present == null ? false : iterator.next());
myIncomingCount++;
}
writeHeader();
myHeaderLoaded = true;
} finally {
closeStreams();
}
return result;
}
Aggregations