List Info

Thread: getFileRevisions using file:/// protocol




getFileRevisions using file:/// protocol
user name
2008-04-22 08:38:02
Hi, all, I saw related postings on this elsewhere, but I
haven't been able to
crack the code, as it were.

I want to check out a file, but in order to do this (using
repository.getFile) I need to supply a valid revision. When
I give it one,

long i = repository.getFile(sFilePath, iRevNum, propMap,
byteoutputstream);

works brilliantly.

But 

coll = repository.getFileRevisions(sFilePath, null,
SVNRevision.UNDEFINED.getNumber(), 0);

returns an error saying it's not a file.

I see if this can't be made to work, that I can get a dir
listing using some
other sample code in the Wiki, iterate over the files in the
dir, and then
pick up the properties. But is getFileRevisions the more
appropriate method?

Please note that I am only skin deep in SVN. My objective is
demonstrating
some integration principles between SVN and an editorial
workflow (content
management) system.

Many thanks,

Harv Greenberg
XyEnterprise
-- 
View this message in context: http://www.nabble.com/g
etFileRevisions-using-file%3A----protocol-tp16824271p1682427
1.html
Sent from the SVNKit - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: svnkit-users-unsubscribesvnkit.com
For additional commands, e-mail: svnkit-users-helpsvnkit.com


Re: getFileRevisions using file:/// protocol
user name
2008-04-22 11:35:34
Hello,

 > I want to check out a file, but in order to do this
(using
 > repository.getFile) I need to supply a valid revision.
When I give it 
one,
You may use -1 as a revision value for getFile to get a
latest revision 
of a file.

Regarding getFileRevisions, the following code works for
me:

SVNURL url =
SVNURL.parseURIEncoded("h
ttp://svn.svnkit.com/repos/svnkit/tags/1.1.7");
SVNRepository repos = SVNRepositoryFactory.create(url);

long revision = repos.getLatestRevision();

Collection revisions =
   repos.getFileRevisions("README.txt",
(Collection) null, 0, revision);

for (Iterator revs = revisions.iterator(); revs.hasNext();)
{
   SVNFileRevision fileRevision = (SVNFileRevision)
revs.next();
   System.out.println(fileRevision.getPath() + " :
" +
                      fileRevision.getRevision());
}

 > returns an error saying it's not a file.
getFileRevision requires endRevision parameter to be valid
revision in 
which file exists, so specifying 0 for the start and valid
revision as 
end revision should make it work properly.

Also, getFileRevisions makes server to report file content
for each 
revision, so this operation is not effective for just
getting revisions 
of a certain file. Alternatively you may use log method:

long revision = repos.getLatestRevision();
Collection logEntries =
     repos.log(new String [] {"README.txt"},
               (Collection) null, revision, 0, false,
false);

for (Iterator logs = logEntries.iterator(); logs.hasNext();)
{
     SVNLogEntry logEntry = (SVNLogEntry) logs.next();
     System.out.println(logEntry.getRevision());
}

This is the simplest way to do that, but it could be more
complicated 
when file was copied in certain revision (i.e. changed it
path in 
repository). Log will report that revision and previous
ones, but to 
call getFile on revision before file was copied you'll have
also to know 
real file path at that very revision. To get that path you
may use 
getLocations(...) method:

Collection logEntries =
     repos.log(new String [] {"README.txt"},
               (Collection) null, revision, 0, false,
false);
for (Iterator logs = logEntries.iterator(); logs.hasNext();)
{
    SVNLogEntry logEntry = (SVNLogEntry) logs.next();
    System.out.println(logEntry.getRevision());

    // get file path as it was at revision using
getLocations
    // pegRevision is revision which we used in log call.
    Collection locations =
      repos.getLocations("README.txt",
             (Collection) null, revision, new
             long[] {logEntry.getRevision()});

    // as we passed long[1] to getLocations there is only
    // one SVNLocationEntry in collection:
    SVNLocationEntry location =
       (SVNLocationEntry) locations.iterator().next();
    System.out.println("path at revision " +
location.getRevision() +
                       " is: " +
location.getPath());

    // now we may call getFile on correct path and
revision:
    repos.getFile(
          location.getPath(), location.getRevision(), null,
System.out);

}

I've tested above code on README.txt file located in 
http://
svn.svnkit.com/repos/svnkit/tags/1.1.7 - history of this
file 
includes several copy operations so it demonstrates how path
of the file 
could change in different revisions well.

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

xyharv wrote:
> Hi, all, I saw related postings on this elsewhere, but
I haven't been able to
> crack the code, as it were.
> 
> I want to check out a file, but in order to do this
(using
> repository.getFile) I need to supply a valid revision.
When I give it one,
> 
> long i = repository.getFile(sFilePath, iRevNum,
propMap, byteoutputstream);
> 
> works brilliantly.
> 
> But 
> 
> coll = repository.getFileRevisions(sFilePath, null,
> SVNRevision.UNDEFINED.getNumber(), 0);
> 
> returns an error saying it's not a file.
> 
> I see if this can't be made to work, that I can get a
dir listing using some
> other sample code in the Wiki, iterate over the files
in the dir, and then
> pick up the properties. But is getFileRevisions the
more appropriate method?
> 
> Please note that I am only skin deep in SVN. My
objective is demonstrating
> some integration principles between SVN and an
editorial workflow (content
> management) system.
> 
> Many thanks,
> 
> Harv Greenberg
> XyEnterprise

------------------------------------------------------------
---------
To unsubscribe, e-mail: svnkit-users-unsubscribesvnkit.com
For additional commands, e-mail: svnkit-users-helpsvnkit.com


Re: getFileRevisions using file:/// protocol
user name
2008-04-22 12:03:14
Oops. Looks like operator error having to do with revision
numbers.
-- 
View this message in context: http://www.nabble.com/g
etFileRevisions-using-file%3A----protocol-tp16824271p1682526
9.html
Sent from the SVNKit - Users mailing list archive at
Nabble.com.


------------------------------------------------------------
---------
To unsubscribe, e-mail: svnkit-users-unsubscribesvnkit.com
For additional commands, e-mail: svnkit-users-helpsvnkit.com


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )