Hello Elvis,

> Can you please provide me some help on how to implement such functionality
> with SVNKit. It would be very useful if you provide some short code example,
> and or which classes and methods I have to use, so I can read the java doc.

I'm not sure if I understand your question correctly, so please feel
free to correct me.

Getting history of a file (all version of a certain file) is a task
very similar to the one performed by 'svn annotate (blame)' command.
It does downloads all versions of the files, runs diff and keeps track
of what lines have been changed at what revision.

SVNKit allows one to plug into annotate algorithm and receive contents
of the file for each revision (and it follows copy operations).

To receive these contents you may use SVNLogClient.doAnnotateMethod
which takes file URL, revisions range and ISVNAnnotateHandler callback
which receives contents of each version of the file prior to
generating full annotation. You may first use this method and later,
if it is what you need, you may implement it basing on the lower API
level (SVNRepository) to improve fetching performance.

Example code snippet will look like:

DAVRepositoryFactory.setup();
SVNRepositoryFactoryImpl.setup();
FSRepositoryFactory.setup();

SVNLogClient client = SVNClientManager.newInstance().getLogClient();
client.doAnnotate(..., new ISVNAnnotateHandler() {
   ..
  public boolean handleRevision(Date date, long revision, String
author, File contents) throws SVNException {
     // process file contents
     return false;
  }
});

Alexander Kitaev,
TMate Software,
http://svnkit.com/ - Java [Sub]Versioning Library!
http://hg4j.com/ - Java Mercurial Library!
http://sqljet.com/ - Java SQLite Library!



On 16 September 2011 18:06, vligu <[email protected]> wrote:
>
> Here is my problem:
>
> I am working on a project as part of my diploma thesis. I am trying to
> connect to different Open Source project repositories and get info from
> source files. Actually we analyze the code of this projects and the changes
> made on it during the time. In other words, we want to see how the software
> evolves and specify the changes made on. Therefore, we need to connect to a
> repository using SVNKit and download for each source file its contents for
> each revision it is changed.
>
> For example let say we have a project with an initial directory structure:
> - dirA/
> -- file1.java
> -- file2.java
>
> The first commit make changes to dirA/file1.java and the second to
> dirA/file2.java and file1.java. We want to analyze the code of two files
> (file1.java and file2.java) at initial state and then the changes that were
> made at file1.java during first and second commit and the changes made at
> file2.java during second commit.
>
> The third commit creates directories and files:
>
> - dirB/
> -- file3.java
>
> - dirA/dirC
> -- file4.java
>
> In the same way as described above we want to analyze the code for
> dirB/file3.java and dirA/dirC/file4.java, as well as we want to analyze how
> the (main) directory structure is changed.
>
> The 4th commit copies the file file3.java to dirA/dirC/ directory and makes
> changes to this file. In the same way we want to analyze how the copy
> operation changed the directory structure and analyze the contents of
> file3.java before and after the commit.
>
> Because we are code oriented we want to get all of the source files from
> repository and all their revisions. For each  revision of a particular file
> we want the contents of current revision (starting from very first revision)
> and the previous one, until the last revision. Because a file is not
> necessary changed at each commit (it might be copied or deleted) there is no
> need to download a duplicate file with same contents.
>
> I know there is a way to retrieve the original state of a file only by
> having its contents at its last revision by recursively performing backward
> diff to its contents. For example having the contents of dirA/file1.java at
> last revision (the one created during second commit) and having the diff
> output we can retrieve the state of file as it was before this revision
> (before second commit). This way there is no need to download each file's
> contents for each revision. So we only have to download the contents of a
> file at the very first revision and then every diff output (if any) for each
> revision and perform forward diff to retrieve the state after commit.
>
> Can you please provide me some help on how to implement such functionality
> with SVNKit. It would be very useful if you provide some short code example,
> and or which classes and methods I have to use, so I can read the java doc.
> Every help will be appreciate.
>
> Thank you in advance,
> Elvis.
> --
> View this message in context: 
> http://old.nabble.com/Downloading-all-files-in-each-resivision-from-a-SVN-repo-using-SVNkit---Please-HELP-tp32480141p32480141.html
> Sent from the SVNKit - Users mailing list archive at Nabble.com.
>
>
>

Reply via email to