Search in sources :

Example 46 with ContentRevision

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

the class SvnChangeDiffViewerProvider method createPropertyRequest.

@NotNull
private static SvnPropertiesDiffRequest createPropertyRequest(@NotNull Change change, @NotNull ProgressIndicator indicator) throws DiffRequestProducerException {
    try {
        Change propertiesChange = getSvnChangeLayer(change);
        if (propertiesChange == null)
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        ContentRevision bRevRaw = propertiesChange.getBeforeRevision();
        ContentRevision aRevRaw = propertiesChange.getAfterRevision();
        if (bRevRaw != null && !(bRevRaw instanceof PropertyRevision)) {
            LOG.warn("Before change is not PropertyRevision");
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        }
        if (aRevRaw != null && !(aRevRaw instanceof PropertyRevision)) {
            LOG.warn("After change is not PropertyRevision");
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        }
        PropertyRevision bRev = (PropertyRevision) bRevRaw;
        PropertyRevision aRev = (PropertyRevision) aRevRaw;
        indicator.checkCanceled();
        List<PropertyData> bContent = bRev != null ? bRev.getProperties() : null;
        indicator.checkCanceled();
        List<PropertyData> aContent = aRev != null ? aRev.getProperties() : null;
        if (aRev == null && bRev == null)
            throw new DiffRequestProducerException(SvnBundle.getString("diff.cant.get.properties.changes"));
        ContentRevision bRevMain = change.getBeforeRevision();
        ContentRevision aRevMain = change.getAfterRevision();
        String title1 = bRevMain != null ? StringUtil.nullize(bRevMain.getRevisionNumber().asString()) : null;
        String title2 = aRevMain != null ? StringUtil.nullize(aRevMain.getRevisionNumber().asString()) : null;
        return new SvnPropertiesDiffRequest(bContent, aContent, title1, title2);
    } catch (VcsException e) {
        throw new DiffRequestProducerException(e);
    }
}
Also used : DiffRequestProducerException(com.intellij.diff.chains.DiffRequestProducerException) PropertyData(org.jetbrains.idea.svn.properties.PropertyData) PropertyRevision(org.jetbrains.idea.svn.history.PropertyRevision) VcsException(com.intellij.openapi.vcs.VcsException) SvnPropertiesDiffRequest(org.jetbrains.idea.svn.difftool.properties.SvnPropertiesDiffRequest) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change) NotNull(org.jetbrains.annotations.NotNull)

Example 47 with ContentRevision

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

the class CmdDiffClient method createChange.

@NotNull
private Change createChange(@NotNull SvnTarget target1, @NotNull SvnTarget target2, @NotNull DiffPath diffPath) throws SvnBindException {
    // TODO: 1) Unify logic of creating Change instance with SvnDiffEditor and SvnChangeProviderContext
    // TODO: 2) If some directory is switched, files inside it are returned as modified in "svn diff --summarize", even if they are equal
    // TODO: to branch files by content - possibly add separate processing of all switched files
    // TODO: 3) Properties change is currently not added as part of result change like in SvnChangeProviderContext.patchWithPropertyChange
    SvnTarget subTarget1 = SvnUtil.append(target1, diffPath.path, true);
    String relativePath = SvnUtil.getRelativeUrl(SvnUtil.toDecodedString(target1), SvnUtil.toDecodedString(subTarget1));
    if (relativePath == null) {
        throw new SvnBindException("Could not get relative path for " + target1 + " and " + subTarget1);
    }
    SvnTarget subTarget2 = SvnUtil.append(target2, FileUtil.toSystemIndependentName(relativePath));
    FilePath target1Path = createFilePath(subTarget1, diffPath.isDirectory());
    FilePath target2Path = createFilePath(subTarget2, diffPath.isDirectory());
    FileStatus status = SvnStatusConvertor.convertStatus(SvnStatusHandler.getStatus(diffPath.itemStatus), SvnStatusHandler.getStatus(diffPath.propertiesStatus));
    // statuses determine changes needs to be done to "target1" to get "target2" state
    ContentRevision beforeRevision = status == FileStatus.ADDED ? null : createRevision(target1Path, target2Path, target1.getPegRevision(), status);
    ContentRevision afterRevision = status == FileStatus.DELETED ? null : createRevision(target2Path, target1Path, target2.getPegRevision(), status);
    return createChange(status, beforeRevision, afterRevision);
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) FileStatus(com.intellij.openapi.vcs.FileStatus) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) CurrentContentRevision(com.intellij.openapi.vcs.changes.CurrentContentRevision) SvnRepositoryContentRevision(org.jetbrains.idea.svn.history.SvnRepositoryContentRevision) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) NotNull(org.jetbrains.annotations.NotNull)

Example 48 with ContentRevision

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

the class SvnDiffEditor method createChange.

private Change createChange(final String path, final FileStatus status) {
    final ContentRevision beforeRevision = createBeforeRevision(path);
    final DiffContentRevision afterRevision = createAfterRevision(path);
    if (myReverse) {
        if (status == FileStatus.ADDED) {
            return new Change(afterRevision, null);
        }
        if (status == FileStatus.DELETED) {
            return new Change(null, beforeRevision);
        }
        return new Change(afterRevision, beforeRevision, status);
    }
    return new Change(status == FileStatus.ADDED ? null : beforeRevision, status == FileStatus.DELETED ? null : afterRevision, status);
}
Also used : CurrentContentRevision(com.intellij.openapi.vcs.changes.CurrentContentRevision) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change)

Example 49 with ContentRevision

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

the class SuperfluousRemover method accept.

protected boolean accept(@NotNull Change change) {
    ContentRevision mainRevision = myCheckBefore ? change.getBeforeRevision() : change.getAfterRevision();
    ContentRevision otherRevision = !myCheckBefore ? change.getBeforeRevision() : change.getAfterRevision();
    if (mainRevision == null || SvnRollbackEnvironment.isMoveRenameReplace(change)) {
        check(otherRevision.getFile().getIOFile());
        return true;
    }
    return false;
}
Also used : ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision)

Example 50 with ContentRevision

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

the class ChangesAfterPathComparator method compare.

@Override
public int compare(Change o1, Change o2) {
    final ContentRevision ar1 = o1.getAfterRevision();
    final ContentRevision ar2 = o2.getAfterRevision();
    return Comparing.compare(ar1, ar2, ourComparator);
}
Also used : ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision)

Aggregations

ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)53 Change (com.intellij.openapi.vcs.changes.Change)32 VirtualFile (com.intellij.openapi.vfs.VirtualFile)18 FilePath (com.intellij.openapi.vcs.FilePath)15 NotNull (org.jetbrains.annotations.NotNull)12 VcsException (com.intellij.openapi.vcs.VcsException)9 GitContentRevision (git4idea.GitContentRevision)9 File (java.io.File)9 FileStatus (com.intellij.openapi.vcs.FileStatus)5 Nullable (org.jetbrains.annotations.Nullable)5 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)4 CurrentContentRevision (com.intellij.openapi.vcs.changes.CurrentContentRevision)4 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)3 GitRevisionNumber (git4idea.GitRevisionNumber)3 AccessToken (com.intellij.openapi.application.AccessToken)2 Project (com.intellij.openapi.project.Project)2 Ref (com.intellij.openapi.util.Ref)2 BinaryContentRevision (com.intellij.openapi.vcs.changes.BinaryContentRevision)2 ByteBackedContentRevision (com.intellij.openapi.vcs.changes.ByteBackedContentRevision)2 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2