Discussion:
Getting First Revision of an entry in SVN using SVNKit 1.8.10
Néstor Boscán
2015-06-24 11:31:59 UTC
Permalink
Hi

I'm trying to get the first revision of the files I'm extracting using
SVNKit 1.8.10. Because I don't see a method or property that return this
value I have to use getFileRevision from 0 to the repository's latest
revision to see which is the first revision. I tried searching from 0 to
the entry latest revision but I get the following error:

"File" is not a file in revision "entry revision"

So each time I want to get the first revision I have to iterate from 0 to
the repository's last revision just to get one revision and it's very slow.
Is there a more efficient way?

Regards,

Néstor
Dmitry Pavlenko
2015-06-24 12:44:53 UTC
Permalink
Hello Nestor,
I'm not sure what you mean by "the first revision" but probably the following code will help:

final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
try {

final SvnLog log = svnOperationFactory.createLog();
log.setStopOnCopy(stopOnCopy);
log.setLimit(1); //get only one revision (the first one)
log.addRange(SvnRevisionRange.create(SVNRevision.create(1), SVNRevision.HEAD));
log.setSingleTarget(SvnTarget.fromURL(url.appendPath("path/to/file", false),
SVNRevision.HEAD));
final SVNLogEntry logEntry = log.run();
final long revision = logEntry.getRevision();
System.out.println("revision = " + revision);
} finally {
svnOperationFactory.dispose();
}


Set 'stopOnCopy' depending on your requirements: if at some revision your "targetFile" was created
as a copy of some "sourceFile", should we consider that revision as the first revision or should we
scan history of "sourceFile" to find the first revision.
--
Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge
Post by Néstor Boscán
Hi
I'm trying to get the first revision of the files I'm extracting using
SVNKit 1.8.10. Because I don't see a method or property that return this
value I have to use getFileRevision from 0 to the repository's latest
revision to see which is the first revision. I tried searching from 0 to
"File" is not a file in revision "entry revision"
So each time I want to get the first revision I have to iterate from 0 to
the repository's last revision just to get one revision and it's very slow.
Is there a more efficient way?
Regards,
Néstor
Néstor Boscán
2015-06-24 14:42:52 UTC
Permalink
Hi Dmitry

Thanks for the quick answer. I'm trying to find for everyfile I read on
SVNKit the revision in which the file was created.

Regards,

Néstor
Post by Dmitry Pavlenko
Hello Nestor,
I'm not sure what you mean by "the first revision" but probably the
final SvnOperationFactory svnOperationFactory = new
SvnOperationFactory();
try {
final SvnLog log = svnOperationFactory.createLog();
log.setStopOnCopy(stopOnCopy);
log.setLimit(1); //get only one revision (the first one)
log.addRange(SvnRevisionRange.create(SVNRevision.create(1), SVNRevision.HEAD));
log.setSingleTarget(SvnTarget.fromURL(url.appendPath("path/to/file", false),
SVNRevision.HEAD));
final SVNLogEntry logEntry = log.run();
final long revision = logEntry.getRevision();
System.out.println("revision = " + revision);
} finally {
svnOperationFactory.dispose();
}
Set 'stopOnCopy' depending on your requirements: if at some revision your
"targetFile" was created
as a copy of some "sourceFile", should we consider that revision as the
first revision or should we
scan history of "sourceFile" to find the first revision.
--
Dmitry Pavlenko,
TMate Software,
http://subgit.com/ - git-svn bridge
Post by Néstor Boscán
Hi
I'm trying to get the first revision of the files I'm extracting using
SVNKit 1.8.10. Because I don't see a method or property that return this
value I have to use getFileRevision from 0 to the repository's latest
revision to see which is the first revision. I tried searching from 0 to
"File" is not a file in revision "entry revision"
So each time I want to get the first revision I have to iterate from 0 to
the repository's last revision just to get one revision and it's very
slow.
Post by Néstor Boscán
Is there a more efficient way?
Regards,
Néstor
Loading...