use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class HgCachingCommittedChangesProvider method getCommittedChanges.
public List<CommittedChangeList> getCommittedChanges(ChangeBrowserSettings changeBrowserSettings, RepositoryLocation repositoryLocation, int maxCount) throws VcsException {
VirtualFile root = ((HgRepositoryLocation) repositoryLocation).getRoot();
HgFile hgFile = new HgFile(root, VcsUtil.getFilePath(root.getPath()));
List<CommittedChangeList> result = new LinkedList<>();
HgLogCommand hgLogCommand = new HgLogCommand(project);
hgLogCommand.setLogFile(false);
List<String> args = null;
if (changeBrowserSettings != null) {
HgLogArgsBuilder argsBuilder = new HgLogArgsBuilder(changeBrowserSettings);
args = argsBuilder.getLogArgs();
if (args.isEmpty()) {
maxCount = maxCount == 0 ? VcsConfiguration.getInstance(project).MAXIMUM_HISTORY_ROWS : maxCount;
}
}
final List<HgFileRevision> localRevisions;
localRevisions = hgLogCommand.execute(hgFile, maxCount == 0 ? -1 : maxCount, true, args);
Collections.reverse(localRevisions);
for (HgFileRevision revision : localRevisions) {
HgRevisionNumber vcsRevisionNumber = revision.getRevisionNumber();
List<HgRevisionNumber> parents = vcsRevisionNumber.getParents();
// can have no parents if it is a root
HgRevisionNumber firstParent = parents.isEmpty() ? null : parents.get(0);
List<Change> changes = new ArrayList<>();
for (String file : revision.getModifiedFiles()) {
changes.add(createChange(root, file, firstParent, file, vcsRevisionNumber, FileStatus.MODIFIED));
}
for (String file : revision.getAddedFiles()) {
changes.add(createChange(root, null, null, file, vcsRevisionNumber, FileStatus.ADDED));
}
for (String file : revision.getDeletedFiles()) {
changes.add(createChange(root, file, firstParent, null, vcsRevisionNumber, FileStatus.DELETED));
}
for (Map.Entry<String, String> copiedFile : revision.getMovedFiles().entrySet()) {
changes.add(createChange(root, copiedFile.getKey(), firstParent, copiedFile.getValue(), vcsRevisionNumber, HgChangeProvider.RENAMED));
}
result.add(new HgCommittedChangeList(myVcs, vcsRevisionNumber, revision.getBranchName(), revision.getCommitMessage(), revision.getAuthor(), revision.getRevisionDate(), changes));
}
Collections.reverse(result);
return result;
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class HgCachingCommittedChangesProvider method getOneList.
@Override
public Pair<CommittedChangeList, FilePath> getOneList(VirtualFile file, VcsRevisionNumber number) throws VcsException {
final ChangeBrowserSettings settings = createDefaultSettings();
settings.USE_CHANGE_AFTER_FILTER = true;
settings.USE_CHANGE_BEFORE_FILTER = true;
settings.CHANGE_AFTER = number.asString();
settings.CHANGE_BEFORE = number.asString();
// todo implement in proper way
VirtualFile localVirtualFile = HgUtil.convertToLocalVirtualFile(file);
if (localVirtualFile == null) {
return null;
}
final FilePath filePath = VcsUtil.getFilePath(localVirtualFile);
final CommittedChangeList list = getCommittedChangesForRevision(getLocationFor(filePath), number.asString());
if (list != null) {
return new Pair<>(list, filePath);
}
return null;
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class CachedProvider method getEarliestRevision.
public long getEarliestRevision() {
if (myEarliestKeepedRevision == -1) {
try {
while (myIterator.hasNext()) {
final ChangesBunch changesBunch = myIterator.next();
if (changesBunch == null) {
break;
}
addToLoaded(changesBunch);
final List<CommittedChangeList> list = myAlreadyReaded.getList();
if (!list.isEmpty()) {
myEarliestKeepedRevision = list.get(0).getNumber();
break;
}
}
} catch (SwitchRevisionsProviderException e) {
// means that committed cache now should be queried instead of internally cached
// just return -1 -> queries will be redirected
myEarliestKeepedRevision = -1;
}
}
return myEarliestKeepedRevision;
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class CachedProvider method createFromLoaded.
@Nullable
private Fragment createFromLoaded(final ChangesBunch loadedBunch, final long earliestRevision, final long oldestRevision, final int desirableSize, final boolean includeYoungest, final boolean includeOldest, final boolean consistent) {
boolean consistentWithPrevious = loadedBunch.isConsistentWithPrevious();
boolean consistentWithYounger = consistent;
final List<CommittedChangeList> list = loadedBunch.getList();
final List<CommittedChangeList> sublist = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
final CommittedChangeList changeList = list.get(i);
if ((!includeOldest) && (changeList.getNumber() == oldestRevision)) {
continue;
}
if (changeList.getNumber() == earliestRevision) {
consistentWithYounger = true;
}
if ((earliestRevision == -1) || (changeList.getNumber() < earliestRevision) || (includeYoungest && (changeList.getNumber() == earliestRevision))) {
sublist.add(changeList);
}
if ((sublist.size() == desirableSize) || (changeList.getNumber() < oldestRevision)) {
if (!consistentWithPrevious) {
consistentWithPrevious = (i > 0);
}
break;
}
}
if (!myHadBeenAccessed) {
myHadBeenAccessed = (!sublist.isEmpty());
}
return (sublist.isEmpty()) ? null : new Fragment(myOrigin, sublist, consistentWithPrevious, consistentWithYounger, loadedBunch);
}
use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.
the class ShowDiffFromAnnotation method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final int actualNumber = currentLine;
if (actualNumber < 0)
return;
final VcsRevisionNumber revisionNumber = myFileAnnotation.getLineRevisionNumber(actualNumber);
if (revisionNumber != null) {
final VcsException[] exc = new VcsException[1];
final List<Change> changes = new LinkedList<>();
final FilePath[] targetPath = new FilePath[1];
ProgressManager.getInstance().run(new Task.Backgroundable(myVcs.getProject(), "Loading revision " + revisionNumber.asString() + " contents", true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
final CommittedChangesProvider provider = myVcs.getCommittedChangesProvider();
try {
final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(myFile, revisionNumber);
if (pair == null || pair.getFirst() == null) {
VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Can not load data for show diff", MessageType.ERROR);
return;
}
targetPath[0] = pair.getSecond() == null ? VcsUtil.getFilePath(myFile) : pair.getSecond();
final CommittedChangeList cl = pair.getFirst();
changes.addAll(cl.getChanges());
Collections.sort(changes, ChangesComparator.getInstance(true));
} catch (VcsException e1) {
exc[0] = e1;
}
}
@Override
public void onSuccess() {
if (exc[0] != null) {
VcsBalloonProblemNotifier.showOverChangesView(myVcs.getProject(), "Can not show diff: " + exc[0].getMessage(), MessageType.ERROR);
} else if (!changes.isEmpty()) {
int idx = findSelfInList(changes, targetPath[0]);
final ShowDiffContext context = new ShowDiffContext(DiffDialogHints.FRAME);
if (idx != -1) {
context.putChangeContext(changes.get(idx), DiffUserDataKeysEx.NAVIGATION_CONTEXT, createDiffNavigationContext(actualNumber));
}
if (ChangeListManager.getInstance(myVcs.getProject()).isFreezedWithNotification(null))
return;
ShowDiffAction.showDiffForChange(myVcs.getProject(), changes, idx, context);
}
}
});
}
}
Aggregations