4

I have used a sample java code to get a file's revision history, but only got one revision. There are many revisions in respository for this file. So how can I get all revisions for this file at once?

…
long startRevision = -1;
long endRevision = 0; //HEAD (i.e. the latest) revision

SVNRepositoryFactoryImpl.setup();
repository = SVNRepositoryFactory.create( SVNURL.parseURIEncoded(url) );
ISVNAuthenticationManager authManager = 
         SVNWCUtil.createDefaultAuthenticationManager( name, password );
repository.setAuthenticationManager( authManager );

Collection logEntries = null;
logEntries = repository.log( new String[] { "EJB.java" }, null, startRevision,
                             endRevision, true, true );
…
stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
bombyx
  • 41
  • 2

2 Answers2

1

Get the logs and get revisions using those logEntries

SVNRepository repository = null;
            repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
            ISVNAuthenticationManager authManager =
                               SVNWCUtil.createDefaultAuthenticationManager("", "");
            repository.setAuthenticationManager(authManager);
            SvnOperationFactory operationFactory = new SvnOperationFactory();
            SvnLog logOperation = operationFactory.createLog();
            logOperation.setSingleTarget(
                    SvnTarget.fromURL(
                            SVNURL.parseURIEncoded(url)));
            logOperation.setRevisionRanges( Collections.singleton(
                    SvnRevisionRange.create(
                            SVNRevision.create( 1 ),
                            SVNRevision.HEAD
                    )
            ) );
            Collection<SVNLogEntry> logEntries = logOperation.run( null );

Now iterate throught the logEntries and use logEntry.getRevision() to get all the revisions till date.

Manas
  • 177
  • 3
  • 13
1

Use 0 for start revision and -1 for end revision

Elvis
  • 817
  • 1
  • 7
  • 19