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);
}
}
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);
}
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);
}
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;
}
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);
}
Aggregations