use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class ImportChangedProjectsCommand method determineChangedFilesOfCommit.
private Set<File> determineChangedFilesOfCommit(RepositoryCommit repoCommit) {
Set<File> changedFilesOfCommit = new HashSet<>();
File rootOfWorkingDirectory = repoCommit.getRepository().getWorkTree();
FileDiff[] fileDiffs = repoCommit.getDiffs();
for (FileDiff fileDiff : fileDiffs) {
// in case of brand new files there is no old path
addIfNotDevNull(changedFilesOfCommit, rootOfWorkingDirectory, fileDiff.getNewPath());
// in case of deletions there is no new path
addIfNotDevNull(changedFilesOfCommit, rootOfWorkingDirectory, fileDiff.getOldPath());
}
return changedFilesOfCommit;
}
use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class CommitEditorPage method loadSections.
void loadSections() {
Job refreshJob = new CommitEditorPageJob(getCommit()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final List<Ref> tags = loadTags();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
final List<Ref> branches = loadBranches();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
final FileDiff[] diffs = getCommit().getDiffs();
updateUI(monitor, () -> {
fillTags(getManagedForm().getToolkit(), tags);
fillDiffs(diffs);
fillBranches(branches);
});
return Status.OK_STATUS;
}
};
refreshJob.schedule();
}
use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class BlameInformationControl method createDiffLinkAndText.
private void createDiffLinkAndText(final RevCommit parent, final Diff diff) throws IOException {
String parentId = parent.toObjectId().abbreviate(7).name();
String parentMessage = parent.getShortMessage();
EditList interestingDiff = getInterestingDiff(diff.getEditList());
final Integer parentLine;
if (!interestingDiff.isEmpty())
parentLine = Integer.valueOf(interestingDiff.get(0).getBeginA());
else
parentLine = null;
Composite header = new Composite(diffComposite, SWT.NONE);
header.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
Label diffHeaderLabel = new Label(header, SWT.NONE);
diffHeaderLabel.setText(NLS.bind(UIText.BlameInformationControl_DiffHeaderLabel, parentId, parentMessage));
showAnnotationsLink = new Link(header, SWT.NONE);
showAnnotationsLink.setText(UIText.BlameInformationControl_ShowAnnotationsLink);
showAnnotationsLinkSelectionAdapter = new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
blameParent(parent, diff, parentLine);
}
};
showAnnotationsLink.addSelectionListener(showAnnotationsLinkSelectionAdapter);
DiffViewer diffText = new DiffViewer(diffComposite, null, SWT.NONE);
diffText.configure(new DiffViewer.Configuration(EditorsUI.getPreferenceStore()));
diffText.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
DiffDocument document = new DiffDocument();
try (DiffRegionFormatter diffFormatter = new DiffRegionFormatter(document)) {
diffFormatter.setContext(1);
diffFormatter.setRepository(revision.getRepository());
diffFormatter.format(interestingDiff, diff.getOldText(), diff.getNewText());
try (ObjectReader reader = revision.getRepository().newObjectReader()) {
DiffEntry diffEntry = CompareCoreUtils.getChangeDiffEntry(revision.getRepository(), revision.getSourcePath(), revision.getCommit(), parent, reader);
if (diffEntry != null) {
FileDiff fileDiff = new FileDiff(revision.getCommit(), diffEntry);
document.setDefault(revision.getRepository(), fileDiff);
}
}
document.connect(diffFormatter);
}
diffText.setDocument(document);
}
use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class StashEditorPage method getUnstagedDiffs.
/**
* @return diffs for unstaged and untracked changes
*/
protected FileDiff[] getUnstagedDiffs() {
List<FileDiff> unstagedDiffs = new ArrayList<>();
RevCommit stagedCommit = getCommit().getRevCommit().getParent(PARENT_COMMIT_STAGED);
List<FileDiff> workingDirDiffs = asList(getCommit().getDiffs(stagedCommit));
unstagedDiffs.addAll(workingDirDiffs);
if (getCommit().getRevCommit().getParentCount() > 2) {
RevCommit untrackedCommit = getCommit().getRevCommit().getParent(PARENT_COMMIT_UNTRACKED);
FileDiff[] untrackedDiffs = new RepositoryCommit(getCommit().getRepository(), untrackedCommit).getDiffs();
unstagedDiffs.addAll(asList(untrackedDiffs));
}
return unstagedDiffs.toArray(new FileDiff[unstagedDiffs.size()]);
}
use of org.eclipse.egit.ui.internal.history.FileDiff in project egit by eclipse.
the class StashEditorPage method loadSections.
@Override
void loadSections() {
RepositoryCommit commit = getCommit();
Job refreshJob = new Job(MessageFormat.format(UIText.CommitEditorPage_JobName, commit.getRevCommit().name())) {
@Override
protected IStatus run(IProgressMonitor monitor) {
final FileDiff[] unstagedDiffs = getUnstagedDiffs();
final FileDiff[] indexDiffs = getStagedDiffs();
final ScrolledForm form = getManagedForm().getForm();
if (UIUtils.isUsable(form))
form.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (!UIUtils.isUsable(form))
return;
fillDiffs(unstagedDiffs);
fillStagedDiffs(indexDiffs);
form.reflow(true);
form.layout(true, true);
}
});
return Status.OK_STATUS;
}
};
refreshJob.setRule(this);
refreshJob.schedule();
}
Aggregations