use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class SvnAnnotationProvider method annotate.
public FileAnnotation annotate(final VirtualFile file) throws VcsException {
final SvnDiffProvider provider = (SvnDiffProvider) myVcs.getDiffProvider();
final SVNRevision currentRevision = ((SvnRevisionNumber) provider.getCurrentRevision(file)).getRevision();
final VcsRevisionDescription lastChangedRevision = provider.getCurrentRevisionDescription(file);
if (lastChangedRevision == null) {
throw new VcsException("Can not get current revision for file " + file.getPath());
}
final SVNRevision svnRevision = ((SvnRevisionNumber) lastChangedRevision.getRevisionNumber()).getRevision();
if (!svnRevision.isValid()) {
throw new VcsException("Can not get last changed revision for file: " + file.getPath() + "\nPlease run svn info for this file and file an issue.");
}
return annotate(file, new SvnFileRevision(myVcs, currentRevision, currentRevision, null, null, null, null, null), lastChangedRevision.getRevisionNumber(), true);
}
use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class SvnAnnotationProvider method annotateNonExisting.
private SvnRemoteFileAnnotation annotateNonExisting(Pair<SvnChangeList, FilePath> pair, VcsFileRevision revision, Info info, Charset charset, final VirtualFile current) throws VcsException, SVNException, IOException {
final File wasFile = pair.getSecond().getIOFile();
final File root = getCommonAncestor(wasFile, info.getFile());
if (root == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
final String relativePath = FileUtil.getRelativePath(root.getPath(), wasFile.getPath(), File.separatorChar);
if (relativePath == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
Info wcRootInfo = myVcs.getInfo(root);
if (wcRootInfo == null || wcRootInfo.getURL() == null) {
throw new VcsException("Can not find relative path for " + wasFile.getPath() + "@" + revision.getRevisionNumber().asString());
}
SVNURL wasUrl = wcRootInfo.getURL();
final String[] strings = relativePath.replace('\\', '/').split("/");
for (String string : strings) {
wasUrl = wasUrl.appendPath(string, true);
}
final SVNRevision svnRevision = ((SvnRevisionNumber) revision.getRevisionNumber()).getRevision();
byte[] data = SvnUtil.getFileContents(myVcs, SvnTarget.fromURL(wasUrl), svnRevision, svnRevision);
final String contents = LoadTextUtil.getTextByBinaryPresentation(data, charset == null ? CharsetToolkit.UTF8_CHARSET : charset).toString();
final SvnRemoteFileAnnotation result = new SvnRemoteFileAnnotation(myVcs, contents, revision.getRevisionNumber(), current);
final AnnotationConsumer annotateHandler = createAnnotationHandler(ProgressManager.getInstance().getProgressIndicator(), result);
boolean calculateMergeinfo = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate() && SvnUtil.checkRepositoryVersion15(myVcs, wasUrl.toString());
AnnotateClient client = myVcs.getFactory().createAnnotateClient();
client.annotate(SvnTarget.fromURL(wasUrl, svnRevision), SVNRevision.create(1), svnRevision, calculateMergeinfo, getLogClientOptions(myVcs), annotateHandler);
return result;
}
use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class CreateBranchOrTagDialog method isOKActionEnabled.
public boolean isOKActionEnabled() {
myErrorLabel.setText(" ");
if (myURL == null) {
return false;
}
if (myBranchOrTagRadioButton.isSelected() && myBranchTagBaseComboBox.getComboBox().getSelectedItem() == null) {
myErrorLabel.setText(SvnBundle.message("create.branch.no.base.location.error"));
return false;
}
String url = getToURL();
if (url != null && url.trim().length() > 0) {
if (myRepositoryRadioButton.isSelected()) {
SVNRevision revision;
try {
revision = myRevisionPanel.getRevision();
} catch (ConfigurationException e) {
revision = SVNRevision.UNDEFINED;
}
if (!revision.isValid() || revision.isLocal()) {
myErrorLabel.setText(SvnBundle.message("create.branch.invalid.revision.error", myRevisionPanel.getRevisionText()));
return false;
}
return true;
} else if (myWorkingCopyRadioButton.isSelected()) {
Info info = SvnVcs.getInstance(myProject).getInfo(mySrcFile);
String srcUrl = info != null && info.getURL() != null ? info.getURL().toString() : null;
if (srcUrl == null) {
myErrorLabel.setText(SvnBundle.message("create.branch.no.working.copy.error", myWorkingCopyField.getText()));
return false;
}
return true;
}
}
return false;
}
use of org.tmatesoft.svn.core.wc.SVNRevision 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.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class SvnChangeProviderContext method createPropertyRevision.
@Nullable
private ContentRevision createPropertyRevision(@NotNull Change change, @NotNull File file, boolean isBeforeRevision) throws SVNException {
FilePath path = ChangesUtil.getFilePath(change);
ContentRevision contentRevision = isBeforeRevision ? change.getBeforeRevision() : change.getAfterRevision();
SVNRevision revision = isBeforeRevision ? SVNRevision.BASE : SVNRevision.WORKING;
return new SimplePropertyRevision(getPropertyList(myVcs, file, revision), path, getRevisionNumber(contentRevision));
}
Aggregations