use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnDiffProvider method createFileContent.
@NotNull
@Override
public ContentRevision createFileContent(@NotNull VcsRevisionNumber revisionNumber, @NotNull VirtualFile selectedFile) {
FilePath filePath = VcsUtil.getFilePath(selectedFile);
SVNRevision svnRevision = ((SvnRevisionNumber) revisionNumber).getRevision();
if (!SVNRevision.HEAD.equals(svnRevision) && revisionNumber.equals(getCurrentRevision(selectedFile))) {
return SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision);
}
// not clear why we need it, with remote check..
Status svnStatus = getFileStatus(VfsUtilCore.virtualToIoFile(selectedFile), false);
return svnStatus != null && svnRevision.equals(svnStatus.getRevision()) ? SvnContentRevision.createBaseRevision(myVcs, filePath, svnRevision) : SvnContentRevision.createRemote(myVcs, filePath, svnRevision);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeProvider method createFileProvider.
@NotNull
private static ISVNStatusFileProvider createFileProvider(@NotNull Map<String, SvnScopeZipper.MyDirNonRecursive> nonRecursiveMap) {
final Map<String, Map<String, File>> result = ContainerUtil.newHashMap();
for (SvnScopeZipper.MyDirNonRecursive item : nonRecursiveMap.values()) {
File file = item.getDir().getIOFile();
Map<String, File> fileMap = ContainerUtil.getOrCreate(result, file.getAbsolutePath(), NAME_TO_FILE_MAP_FACTORY);
for (FilePath path : item.getChildrenList()) {
fileMap.put(path.getName(), path.getIOFile());
}
// see http://issues.tmatesoft.com/issue/SVNKIT-567 for details
if (file.getParentFile() != null) {
Map<String, File> parentMap = ContainerUtil.getOrCreate(result, file.getParentFile().getAbsolutePath(), NAME_TO_FILE_MAP_FACTORY);
parentMap.put(file.getName(), file);
}
}
return parent -> result.get(parent.getAbsolutePath());
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeProvider method processCopiedFile.
private void processCopiedFile(@NotNull SvnChangedFile copiedFile, @NotNull SvnChangeProviderContext context, @Nullable VcsDirtyScope dirtyScope) throws SVNException {
boolean foundRename = false;
final Status copiedStatus = copiedFile.getStatus();
final String copyFromURL = ObjectUtils.assertNotNull(copiedFile.getCopyFromURL());
final Set<SvnChangedFile> deletedToDelete = new HashSet<>();
for (SvnChangedFile deletedFile : context.getDeletedFiles()) {
final Status deletedStatus = deletedFile.getStatus();
if (deletedStatus.getURL() != null && Comparing.equal(copyFromURL, deletedStatus.getURL().toString())) {
final String clName = SvnUtil.getChangelistName(copiedFile.getStatus());
applyMovedChange(context, copiedFile.getFilePath(), dirtyScope, deletedToDelete, deletedFile, copiedStatus, clName);
for (SvnChangedFile deletedChild : context.getDeletedFiles()) {
final Status childStatus = deletedChild.getStatus();
final SVNURL childUrl = childStatus.getURL();
if (childUrl == null) {
continue;
}
final String childURL = childUrl.toDecodedString();
if (StringUtil.startsWithConcatenation(childURL, copyFromURL, "/")) {
String relativePath = childURL.substring(copyFromURL.length());
File newPath = new File(copiedFile.getFilePath().getIOFile(), relativePath);
FilePath newFilePath = myFactory.createFilePathOn(newPath);
if (!context.isDeleted(newFilePath)) {
applyMovedChange(context, newFilePath, dirtyScope, deletedToDelete, deletedChild, context.getTreeConflictStatus(newPath), clName);
}
}
}
foundRename = true;
break;
}
}
final List<SvnChangedFile> deletedFiles = context.getDeletedFiles();
for (SvnChangedFile file : deletedToDelete) {
deletedFiles.remove(file);
}
// by building a relative url
if (!foundRename && copiedStatus.getURL() != null) {
File wcPath = myVcs.getSvnFileUrlMapping().getLocalPath(copyFromURL);
if (wcPath != null) {
Status status;
try {
status = myVcs.getFactory(wcPath).createStatusClient().doStatus(wcPath, false);
} catch (SvnBindException ex) {
LOG.info(ex);
status = null;
}
if (status != null && status.is(StatusType.STATUS_DELETED)) {
final FilePath filePath = myFactory.createFilePathOnDeleted(wcPath, false);
final SvnContentRevision beforeRevision = SvnContentRevision.createBaseRevision(myVcs, filePath, status.getRevision());
final ContentRevision afterRevision = CurrentContentRevision.create(copiedFile.getFilePath());
context.getBuilder().processChangeInList(context.createMovedChange(beforeRevision, afterRevision, copiedStatus, status), SvnUtil.getChangelistName(status), SvnVcs.getKey());
foundRename = true;
}
}
}
if (!foundRename) {
// for debug
LOG.info("Rename not found for " + copiedFile.getFilePath().getPresentableUrl());
context.processStatus(copiedFile.getFilePath(), copiedStatus);
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeProviderContext method loadEntriesFile.
/**
* Ensures that the contents of the 'entries' file is cached in the VFS, so that the VFS will send
* correct events when the 'entries' file is changed externally (to be received by SvnEntriesFileListener)
*
* @param filePath the path of a changed file.
*/
private void loadEntriesFile(@NotNull FilePath filePath) {
final FilePath parentPath = filePath.getParentPath();
if (parentPath == null) {
return;
}
refreshDotSvnAndEntries(parentPath);
if (filePath.isDirectory()) {
refreshDotSvnAndEntries(filePath);
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeProviderContext method createPropertyRevision.
@Nullable
private ContentRevision createPropertyRevision(@NotNull Change change, @NotNull File file, boolean isBeforeRevision) throws SVNException {
FilePath path = ChangesUtil.getFilePath(change);
ContentRevision contentRevision = isBeforeRevision ? change.getBeforeRevision() : change.getAfterRevision();
SVNRevision revision = isBeforeRevision ? SVNRevision.BASE : SVNRevision.WORKING;
return new SimplePropertyRevision(getPropertyList(myVcs, file, revision), path, getRevisionNumber(contentRevision));
}
Aggregations