use of org.jetbrains.idea.svn.status.Status in project intellij-community by JetBrains.
the class CmdCheckinClient method filterCommittables.
@NotNull
private List<File> filterCommittables(@NotNull List<File> committables) throws SvnBindException {
final Set<String> childrenOfSomebody = ContainerUtil.newHashSet();
new AbstractFilterChildren<File>() {
@Override
protected void sortAscending(List<File> list) {
Collections.sort(list);
}
@Override
protected boolean isAncestor(File parent, File child) {
// strict here will ensure that for case insensitive file systems paths different only by case will not be treated as ancestors
// of each other which is what we need to perform renames from one case to another on Windows
final boolean isAncestor = FileUtil.isAncestor(parent, child, true);
if (isAncestor) {
childrenOfSomebody.add(child.getPath());
}
return isAncestor;
}
}.doFilter(ContainerUtil.newArrayList(committables));
if (!childrenOfSomebody.isEmpty()) {
List<File> result = ContainerUtil.newArrayList();
StatusClient statusClient = myFactory.createStatusClient();
for (File file : committables) {
if (!childrenOfSomebody.contains(file.getPath())) {
result.add(file);
} else {
try {
final Status status = statusClient.doStatus(file, false);
if (status != null && !StatusType.STATUS_NONE.equals(status.getContentsStatus()) && !StatusType.STATUS_UNVERSIONED.equals(status.getContentsStatus())) {
result.add(file);
}
} catch (SvnBindException e) {
// not versioned
LOG.info(e);
throw e;
}
}
}
return result;
}
return committables;
}
use of org.jetbrains.idea.svn.status.Status 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 org.jetbrains.idea.svn.status.Status 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 org.jetbrains.idea.svn.status.Status in project intellij-community by JetBrains.
the class SvnFileSystemListener method copy.
@Nullable
public File copy(final VirtualFile file, final VirtualFile toDir, final String copyName) throws IOException {
startOperation(file);
SvnVcs vcs = getVCS(toDir);
if (vcs == null) {
vcs = getVCS(file);
}
if (vcs == null) {
return null;
}
File srcFile = virtualToIoFile(file);
File destFile = new File(virtualToIoFile(toDir), copyName);
if (!SvnUtil.isSvnVersioned(vcs, destFile.getParentFile()) && !isPendingAdd(vcs.getProject(), toDir)) {
return null;
}
if (!SvnUtil.isSvnVersioned(vcs, srcFile.getParentFile())) {
myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false));
return null;
}
final Status fileStatus = getFileStatus(vcs, srcFile);
if (fileStatus != null && fileStatus.is(StatusType.STATUS_ADDED)) {
myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false));
return null;
}
if (sameRoot(vcs, file.getParent(), toDir)) {
myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, srcFile, false));
return null;
}
myAddedFiles.putValue(vcs.getProject(), new AddedFileInfo(toDir, copyName, null, false));
return null;
}
use of org.jetbrains.idea.svn.status.Status in project intellij-community by JetBrains.
the class SvnFileSystemListener method fillDeletedFiles.
private void fillDeletedFiles(Project project, List<Pair<FilePath, WorkingCopyFormat>> deletedFiles, Collection<FilePath> deleteAnyway) throws VcsException {
final SvnVcs vcs = SvnVcs.getInstance(project);
final Collection<File> files = myDeletedFiles.remove(project);
for (final File file : files) {
final Status status = new RepeatSvnActionThroughBusy() {
@Override
protected void executeImpl() throws VcsException {
myT = vcs.getFactory(file).createStatusClient().doStatus(file, false);
}
}.compute();
final FilePath filePath = VcsUtil.getFilePath(file);
if (StatusType.STATUS_ADDED.equals(status.getNodeStatus())) {
deleteAnyway.add(filePath);
} else {
deletedFiles.add(Pair.create(filePath, vcs.getWorkingCopyFormat(file)));
}
}
}
Aggregations