use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class DiffShelvedChangesAction method processTextChanges.
private static void processTextChanges(@NotNull final Project project, @NotNull List<ShelvedChange> changesFromFirstList, @NotNull List<MyDiffRequestProducer> diffRequestProducers) {
final String base = project.getBasePath();
final ApplyPatchContext patchContext = new ApplyPatchContext(project.getBaseDir(), 0, false, false);
final PatchesPreloader preloader = new PatchesPreloader(project);
for (final ShelvedChange shelvedChange : changesFromFirstList) {
final String beforePath = shelvedChange.getBeforePath();
final String afterPath = shelvedChange.getAfterPath();
final FilePath filePath = VcsUtil.getFilePath(new File(base, afterPath == null ? beforePath : afterPath));
final boolean isNewFile = FileStatus.ADDED.equals(shelvedChange.getFileStatus());
// isNewFile -> parent directory, !isNewFile -> file
final VirtualFile file;
try {
file = ApplyFilePatchBase.findPatchTarget(patchContext, beforePath, afterPath, isNewFile);
if (!isNewFile && (file == null || !file.exists()))
throw new FileNotFoundException(beforePath);
} catch (IOException e) {
diffRequestProducers.add(new MyDiffRequestProducer(shelvedChange, filePath) {
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
throw new DiffRequestProducerException("Cannot find base for '" + (beforePath != null ? beforePath : afterPath) + "'");
}
});
continue;
}
diffRequestProducers.add(new MyDiffRequestProducer(shelvedChange, filePath) {
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
if (!isNewFile && file.getFileType() == UnknownFileType.INSTANCE) {
return new UnknownFileTypeDiffRequest(file, getName());
}
if (shelvedChange.isConflictingChange(project)) {
try {
final CommitContext commitContext = new CommitContext();
final TextFilePatch patch = preloader.getPatch(shelvedChange, commitContext);
final FilePath pathBeforeRename = patchContext.getPathBeforeRename(file);
final String relativePath = patch.getAfterName() == null ? patch.getBeforeName() : patch.getAfterName();
final Getter<CharSequence> baseContentGetter = new Getter<CharSequence>() {
@Override
public CharSequence get() {
BaseRevisionTextPatchEP baseRevisionTextPatchEP = Extensions.findExtension(PatchEP.EP_NAME, project, BaseRevisionTextPatchEP.class);
return baseRevisionTextPatchEP.provideContent(relativePath, commitContext);
}
};
Getter<ApplyPatchForBaseRevisionTexts> getter = new Getter<ApplyPatchForBaseRevisionTexts>() {
@Override
public ApplyPatchForBaseRevisionTexts get() {
return ApplyPatchForBaseRevisionTexts.create(project, file, pathBeforeRename, patch, baseContentGetter);
}
};
return PatchDiffRequestFactory.createConflictDiffRequest(project, file, patch, "Shelved Version", getter, getName(), context, indicator);
} catch (VcsException e) {
throw new DiffRequestProducerException("Can't show diff for '" + getName() + "'", e);
}
} else {
final Change change = shelvedChange.getChange(project);
return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
}
}
});
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class DiffShelvedChangesAction method processBinaryFiles.
private static void processBinaryFiles(@NotNull final Project project, @NotNull List<ShelvedBinaryFile> files, @NotNull List<MyDiffRequestProducer> diffRequestProducers) {
final String base = project.getBaseDir().getPath();
for (final ShelvedBinaryFile shelvedChange : files) {
final File file = new File(base, shelvedChange.AFTER_PATH == null ? shelvedChange.BEFORE_PATH : shelvedChange.AFTER_PATH);
final FilePath filePath = VcsUtil.getFilePath(file);
diffRequestProducers.add(new MyDiffRequestProducer(shelvedChange, filePath) {
@NotNull
@Override
public DiffRequest process(@NotNull UserDataHolder context, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException, ProcessCanceledException {
Change change = shelvedChange.createChange(project);
return PatchDiffRequestFactory.createDiffRequest(project, change, getName(), context, indicator);
}
});
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class CommonBinaryFilePatchInProgress method getNewContentRevision.
@Override
public ContentRevision getNewContentRevision() {
if (FilePatchStatus.DELETED.equals(myStatus))
return null;
if (myNewContentRevision != null)
return myNewContentRevision;
if (myPatch.getAfterFileName() != null) {
FilePath newFilePath = getFilePath();
myNewContentRevision = createNewContentRevision(newFilePath);
}
return myNewContentRevision;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ChangelistConflictTracker method clearChanges.
private void clearChanges(Collection<Change> changes) {
for (Change change : changes) {
ContentRevision revision = change.getAfterRevision();
if (revision != null) {
FilePath filePath = revision.getFile();
String path = filePath.getPath();
final Conflict wasRemoved = myConflicts.remove(path);
final VirtualFile file = filePath.getVirtualFile();
if (wasRemoved != null && file != null) {
myEditorNotifications.updateNotifications(file);
// we need to update status
myFileStatusManager.fileStatusChanged(file);
}
}
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class AbstractFilePatchInProgress method getCurrentRevision.
private ContentRevision getCurrentRevision() {
if (FilePatchStatus.ADDED.equals(myStatus))
return null;
if (myCurrentRevision == null) {
FilePath filePath = (myCurrentBase != null) ? VcsUtil.getFilePath(myCurrentBase) : VcsUtil.getFilePath(myIoCurrentBase, false);
myCurrentRevision = new CurrentContentRevision(filePath);
}
return myCurrentRevision;
}
Aggregations