How do I download a random file from VCS repository, given repository path?

Hi,

I have the following:

  • SVN repository URL

  • path to the file in SVN repository


I would like to be able to show diff of two revisions of a file. The file may or may not be a part of the project that is currently open - but it is located in the same repository as the currently open project - let's say it is just some random file, with the common SVN root with files in the open project

How do I do that? Can this be done?

I have tried several things in the com.intellij.openapi.vcs package, but so far I am unable to create a proper VirtualFiles and their revisions to pass to SimpleDiffRequest's setContents() method.

Any suggestions?

Regards
Janusz

1 comment
Comment actions Permalink

Hello Janusz,

I have the following:

  • SVN repository URL

  • path to the file in SVN repository

I would like to be able to show diff of two revisions of a file. The
file may or may not be a part of the project that is currently open -
but it is located in the same repository as the currently open
project - let's say it is just some random file, with the common SVN
root with files in the open project

How do I do that? Can this be done?

I have tried several things in the com.intellij.openapi.vcs package,
but so far I am unable to create a proper VirtualFiles and their
revisions to pass to SimpleDiffRequest's setContents() method.


You don't really need to have a VirtualFile for initializing a DiffRequest.

The API to use in this case is SvnRepositoryContentRevision.create(). This
is not part of the common VCS API, but rather part of the Subversion plugin,
so you'll need to mark your plugin as dependent on the Subversion plugin.

After that, you can create a Change object from the two revisions that you
have, and use ShowDiffAction.showDiffForChanges() to show the diff automatically
without bothering with SimpleDiffRequest yourself.

(You do know that the Subversion plugin is open-source, right?)

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

Please sign in to leave a comment.