Hello Alexander, thank you so much for your help. Actually this is one of the
methods I needed, with some exceptions.
To be more specific about my question I will try to explain it by a simple
example.
Let say I have only one source file which has only 5 revisions (let say it
has been modified 5 times). Let say I want to compute a graph where lines of
code (LOC) are shown per each modification. So my graph will have: revision
0, 3 lines where added, revision 1, 1 line was added, revision 3, 2 lines
was removed, and so on, until 5th revision. There are some solutions to do
this:
1) Download file contents for each revision, and for every current revision
do a diff with the previous one and get the differences
(SVNRepository.getFile()).
2) Download all diff (deltas) for each revision. Having only deltas its more
efficient because I can generate file content for a specific revision,
starting from the first one. Further more, it requires you to download only
deltas so bandwidth is optimized.
These two solutions and the one you provided has something in common:
performance.
I am developing a software which analyze source code and provide visual
reports. The problem is that I cant download each time file contents from
the server, not or deltas, because if I run the program to show a graph for
all files and for each revision, there would be a performance bottleneck,
that is, if we have 100 source files with 1000 revision each, it has to
download 100.000 different contents (or deltas), so the reports would need
more than one day to complete! If repository was locally located than that
would not be a problem for me, but I run this program against well known
sites such as apache.org.
That is why I need to get all file contents (or deltas) at once per each
file for all revisions, or if that is possible to do it recursively on a
directory.
One of the solutions I come up is this (and I will need some help on
implementing it):
1) Download all history logs (and changed paths)
2) For each log do: for each changed path, if it is a file and it is a
modification (log type = M)
3) Call SVNRepository.update() and get file (path) delta, and store it
locally.
With this solution I only have to make (for the previous example) 1000 calls
and in each call (a connect with the server would need to be done, so this
is expensive) download deltas per each modified file in current revision.
So as you see this optimizes bandwidth. To implement this I would need help
on how to implement ReporterButton and Editor.
The solution you provided seems to be more efficient but I am unfamiliar
with svn --annotate.
In other words: I need a "shadow" copy of repository history for a set of
specified paths (let say ../../trunk/opensource/project/.. for all contents
under this directory) so I can run quickly any report. If I had the
repository at my local machine there would have not been a problem.
If you understand me now, and have any suggestion I would be very happy to
hear from you.
Thank you again Alexander.
Elvis Ligu
Department of Applied Informatics,
University Of Macedonia
Greece, Thessaloniki
AlexanderKitaev wrote:
>
> 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.
>>
>>
>>
>
>
>
--
View this message in context:
http://old.nabble.com/Downloading-all-files-in-each-resivision-from-a-SVN-repo-using-SVNkit---Please-HELP-tp32480141p32532852.html
Sent from the SVNKit - Users mailing list archive at Nabble.com.