Search in sources :

Example 1 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class HgUtil method getOriginalFileName.

@NotNull
public static FilePath getOriginalFileName(@NotNull FilePath filePath, ChangeListManager changeListManager) {
    Change change = changeListManager.getChange(filePath);
    if (change == null) {
        return filePath;
    }
    FileStatus status = change.getFileStatus();
    if (status == HgChangeProvider.COPIED || status == HgChangeProvider.RENAMED) {
        ContentRevision beforeRevision = change.getBeforeRevision();
        assert beforeRevision != null : "If a file's status is copied or renamed, there must be an previous version";
        return beforeRevision.getFile();
    } else {
        return filePath;
    }
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class HgUtil method getDiff.

@NotNull
public static List<Change> getDiff(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final FilePath path, @Nullable final HgRevisionNumber revNum1, @Nullable final HgRevisionNumber revNum2) {
    HgStatusCommand statusCommand;
    if (revNum1 != null) {
        //rev2==null means "compare with local version"
        statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(!path.isDirectory()).baseRevision(revNum1).targetRevision(revNum2).build(project);
    } else {
        //rev1 and rev2 can't be null both//
        LOG.assertTrue(revNum2 != null, "revision1 and revision2 can't both be null. Path: " + path);
        //get initial changes//
        statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(false).baseRevision(revNum2).build(project);
    }
    Collection<HgChange> hgChanges = statusCommand.executeInCurrentThread(root, Collections.singleton(path));
    List<Change> changes = new ArrayList<>();
    //convert output changes to standard Change class
    for (HgChange hgChange : hgChanges) {
        FileStatus status = convertHgDiffStatus(hgChange.getStatus());
        if (status != FileStatus.UNKNOWN) {
            changes.add(HgHistoryUtil.createChange(project, root, hgChange.beforeFile().getRelativePath(), revNum1, hgChange.afterFile().getRelativePath(), revNum2, status));
        }
    }
    return changes;
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) Change(com.intellij.openapi.vcs.changes.Change) HgStatusCommand(org.zmlx.hg4idea.command.HgStatusCommand) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class SvnChangeProviderContext method processStatus.

void processStatus(@NotNull FilePath filePath, @NotNull Status status) throws SVNException {
    WorkingCopyFormat format = myVcs.getWorkingCopyFormat(filePath.getIOFile());
    if (!WorkingCopyFormat.UNKNOWN.equals(format) && format.less(WorkingCopyFormat.ONE_DOT_SEVEN)) {
        loadEntriesFile(filePath);
    }
    FileStatus fStatus = SvnStatusConvertor.convertStatus(status);
    final StatusType statusType = status.getContentsStatus();
    if (status.is(StatusType.STATUS_UNVERSIONED, StatusType.UNKNOWN)) {
        final VirtualFile file = filePath.getVirtualFile();
        if (file != null) {
            myChangelistBuilder.processUnversionedFile(file);
        }
    } else if (status.is(StatusType.STATUS_ADDED)) {
        processChangeInList(null, CurrentContentRevision.create(filePath), fStatus, status);
    } else if (status.is(StatusType.STATUS_CONFLICTED, StatusType.STATUS_MODIFIED, StatusType.STATUS_REPLACED) || status.isProperty(StatusType.STATUS_MODIFIED, StatusType.STATUS_CONFLICTED)) {
        processChangeInList(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), fStatus, status);
        checkSwitched(filePath, status, fStatus);
    } else if (status.is(StatusType.STATUS_DELETED)) {
        processChangeInList(SvnContentRevision.createBaseRevision(myVcs, filePath, status), null, fStatus, status);
    } else if (status.is(StatusType.STATUS_MISSING)) {
        myChangelistBuilder.processLocallyDeletedFile(new SvnLocallyDeletedChange(filePath, getState(status)));
    } else if (status.is(StatusType.STATUS_IGNORED)) {
        VirtualFile file = filePath.getVirtualFile();
        if (file == null) {
            file = LocalFileSystem.getInstance().refreshAndFindFileByPath(filePath.getPath());
        }
        if (file == null) {
            LOG.error("No virtual file for ignored file: " + filePath.getPresentableUrl() + ", isNonLocal: " + filePath.isNonLocal());
        } else if (!myVcs.isWcRoot(filePath)) {
            myChangelistBuilder.processIgnoredFile(filePath.getVirtualFile());
        }
    } else if ((fStatus == FileStatus.NOT_CHANGED || fStatus == FileStatus.SWITCHED) && statusType != StatusType.STATUS_NONE) {
        VirtualFile file = filePath.getVirtualFile();
        if (file != null && FileDocumentManager.getInstance().isFileModified(file)) {
            processChangeInList(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), FileStatus.MODIFIED, status);
        } else if (status.getTreeConflict() != null) {
            myChangelistBuilder.processChange(createChange(SvnContentRevision.createBaseRevision(myVcs, filePath, status), CurrentContentRevision.create(filePath), FileStatus.MODIFIED, status), SvnVcs.getKey());
        }
        checkSwitched(filePath, status, fStatus);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileStatus(com.intellij.openapi.vcs.FileStatus) StatusType(org.jetbrains.idea.svn.status.StatusType)

Example 4 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class SvnChangeProviderContext method createPropertyChange.

@NotNull
private Change createPropertyChange(@NotNull Change change, @NotNull Status svnStatus, @Nullable Status deletedStatus) throws SVNException {
    final File ioFile = ChangesUtil.getFilePath(change).getIOFile();
    final File beforeFile = deletedStatus != null ? deletedStatus.getFile() : ioFile;
    // TODO: There are cases when status output is like (on newly added file with some properties that is locally deleted)
    // <entry path="some_path"> <wc-status item="missing" revision="-1" props="modified"> </wc-status> </entry>
    // TODO: For such cases in current logic we'll have Change with before revision containing SVNRevision.UNDEFINED
    // TODO: Analyze if this logic is OK or we should update flow somehow (for instance, to have null before revision)
    ContentRevision beforeRevision = !svnStatus.isProperty(StatusType.STATUS_ADDED) || deletedStatus != null ? createPropertyRevision(change, beforeFile, true) : null;
    ContentRevision afterRevision = !svnStatus.isProperty(StatusType.STATUS_DELETED) ? createPropertyRevision(change, ioFile, false) : null;
    FileStatus status = deletedStatus != null ? FileStatus.MODIFIED : SvnStatusConvertor.convertPropertyStatus(svnStatus.getPropertiesStatus());
    return new Change(beforeRevision, afterRevision, status);
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with FileStatus

use of com.intellij.openapi.vcs.FileStatus in project intellij-community by JetBrains.

the class SvnIgnoreTest method testImpl.

private void testImpl(VirtualFile file) {
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    clManager.ensureUpToDate(false);
    Assert.assertTrue(clManager.getDefaultChangeList().getChanges().isEmpty());
    VcsDirtyScopeManager.getInstance(myProject).fileDirty(file);
    clManager.ensureUpToDate(false);
    Assert.assertTrue(clManager.getDefaultChangeList().getChanges().isEmpty());
    final FileStatus status = clManager.getStatus(file);
    Assert.assertTrue(status.getText(), FileStatus.IGNORED.equals(status));
}
Also used : FileStatus(com.intellij.openapi.vcs.FileStatus)

Aggregations

FileStatus (com.intellij.openapi.vcs.FileStatus)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 Change (com.intellij.openapi.vcs.changes.Change)7 NotNull (org.jetbrains.annotations.NotNull)6 FilePath (com.intellij.openapi.vcs.FilePath)5 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)5 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)4 FileStatusManager (com.intellij.openapi.vcs.FileStatusManager)3 ArrayList (java.util.ArrayList)3 PsiElement (com.intellij.psi.PsiElement)2 GitContentRevision (git4idea.GitContentRevision)2 RefElement (com.intellij.codeInspection.reference.RefElement)1 RefEntity (com.intellij.codeInspection.reference.RefEntity)1 NavigationItemFileStatus (com.intellij.navigation.NavigationItemFileStatus)1 Application (com.intellij.openapi.application.Application)1 FilePatch (com.intellij.openapi.diff.impl.patch.FilePatch)1 TextAttributes (com.intellij.openapi.editor.markup.TextAttributes)1 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)1 Project (com.intellij.openapi.project.Project)1 InvalidDataException (com.intellij.openapi.util.InvalidDataException)1