}
AbstractVcs vcs = VcsUtil.getVcsFor(project, vFile);
assert vcs != null;
VcsRevisionNumber vcsRevisionNumber;
try
{
vcsRevisionNumber = vcs.parseRevisionNumber(rev);
}
catch (VcsException e)
{
throw new RevuFriendlyException("Failed to parse VCS revision number: " + rev,
RevuBundle.message("friendlyError.failedToFetchVcsFile.invalidRevision.details.text",
vFile.getPath(), rev));
}
ContentRevision contentRevision = diffProvider.createFileContent(vcsRevisionNumber, vFile);
String content = null;
if (contentRevision != null)
{
try
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("Fetching from VCS:" + contentRevision);
}
content = contentRevision.getContent();
}
catch (VcsException e)
{
throw new RevuFriendlyException("Error while retrieving VCS content: " + contentRevision,
null, RevuBundle.message("friendlyError.failedToFetchVcsFile.vcsError.details.text",
RevuBundle.message("general.vcsFileAndRev.text", vFile.getPath(), rev), e.getMessage()), e);
}
}
if (content == null)
{
throw new RevuFriendlyException("VCS fetched content is null: ",
RevuBundle.message("friendlyError.failedToFetchVcsFile.nullContent.details.text",
vFile.getPath(), contentRevision));
}
return new VcsVirtualFile(contentRevision.getFile().getPath(), content.getBytes(),
vcsRevisionNumber.asString(), vFile.getFileSystem());
}