use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class ChangesTreeList method seemsToBeMoved.
private static boolean seemsToBeMoved(Change change, VirtualFile toSelect) {
ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision == null)
return false;
FilePath file = afterRevision.getFile();
return FileUtil.pathsEqual(file.getPath(), toSelect.getPath());
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class SingleCommittedListProvider method calculate.
private void calculate() throws VcsException {
// TODO: "svn log -r HEAD:<revisionBefore>" and track copies manually (which also is not correct for all cases).
if (!searchForUrl(svnRootUrl) && !(hasAccess(repositoryUrl) && searchForUrl(repositoryUrl))) {
filePath = searchFromHead(svnRootUrl);
} else {
if (changeList[0].getChanges().size() == 1) {
final ContentRevision afterRevision = changeList[0].getChanges().iterator().next().getAfterRevision();
filePath = afterRevision != null ? afterRevision.getFile() : filePath;
} else {
final Change targetChange = changeList[0].getByPath(repositoryRelativeUrl);
filePath = targetChange == null ? searchFromHead(svnRootUrl) : filePath;
}
}
}
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);
}
Aggregations