1

I am currently working on a project about calculations.I have done the main part of my project,Also integrated SVN Commit function to my code (using .ini file to read the specific address etc. )

I can easily Commit the files, what I am trying is I want to implement the real-time log to my console. Is there any way to implement the log to the console ? Not the general log but the commit log which should be real time.

  • I am using eclipse for mac, I've heard about SVNKit but I am really poor about SVN.

Thanks in advance for any information

--- EDIT ---

This is the code for reading the svn commands from .ini file

public static String iniSVNOkut(String deger, String getObje, String fetchObje){

        Ini uzantilariAlIni = null;

        try 
        {
            String uzantiAyarlari = "Uzantilar.ini";    

            try 
            {
                uzantilariAlIni = new Ini(new FileReader(uzantiAyarlari));
            }
            catch (InvalidFileFormatException e)
            {
                System.err.print("Hata InvalidFileFormat : " + e.getMessage() + "\n" );
                e.printStackTrace();
            }
            catch(FileNotFoundException e)
            {
                System.err.print("Hata FileNotFoundException : " + e.getMessage() + "\n" );
                e.printStackTrace();
            }
            catch (IOException e)
            {
                System.err.print("Hata IOException : " + e.getMessage() + "\n" );
                e.printStackTrace();
            }
        return  deger = uzantilariAlIni.get(getObje).fetch(fetchObje);


        } 
        finally 
        {

        }

    }

This is what .ini includes

[svnAdresi]
svnAdresiniAl = svn co http://svn.svnkit.com/repos/svnkit/trunk/ /Users/sample/Documents/workspace/SatirHesaplaGUI/svnTestMAC

This is how I call it

String svnAdresi;
        svnAdresi = IniFonksiyon.iniSVNOkut(svnAdresi, "svnAdresi", "svnAdresiniAl");
    Runtime cmdCalistir = Runtime.getRuntime();

    try
    {
        Process islem = cmdCalistir.exec(svnAdresi);
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }

1 Answer 1

2

If I understand your question correctly, you want to read the Subversion commit log into your console application.

The easiest way is to use SVNKit.

Here's how I did it.

private static List<SVNLogEntry> logEntryList;

    /*
     * Gets the Subversion log records for the directory
     */
    LogHandler handler = new LogHandler();
    String[] paths = { directory };
    try {
        repository.log(paths, latestRevision, 1L, false, true, handler);
    } catch (SVNException svne) {
        if (svne.getMessage().contains("not found")) {
            logEntryList = new ArrayList<SVNLogEntry>();
        } else {
            CobolSupportLog.logError(
                    "Error while fetching the repository history: "
                            + svne.getMessage(), svne);
            return false;
        }
    }

    logEntryList = handler.getLogEntries();
  • directory - string pointing to a particular directory or module
  • latestRevision - largest revision number from Subversion. Placing the latestRevision second in the log method invocation returns the log records in most recent order.

If you want the log records in sequential order, from 1 to latestRevision, then the 1L would be placed second, and the latestRevision would be placed third.

  • repository - Subversion repository that you've already authenticated.

Here's LogHandler.

public class LogHandler implements ISVNLogEntryHandler {

    protected static final int REVISION_LIMIT = 5;

    protected List<SVNLogEntry> logEntryList;

    public LogHandler() {
        logEntryList = new ArrayList<SVNLogEntry>();
    }

    public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
        logEntryList.add(logEntry); 
    }

    public List<SVNLogEntry> getLogEntries() {
        if (logEntryList.size() <= REVISION_LIMIT) {
            return logEntryList;
        } else {
            return logEntryList.subList(0, REVISION_LIMIT);
        }
    }

}  
Sign up to request clarification or add additional context in comments.

7 Comments

Good answer, I'll just add that you could specify REVISION_LIMIT to log() method directly. Then they won't be loaded on the server and transformed via network. This could significantly speed up your implementation if the repository has a lot of revisions.
Thank you very much! Thats exactly what I need, and would it matter that much if we wouldnt specify REVISION_LIMIT ? Since the repository I am working on has a LOT of revisions
@Yesilmen: No, you don't have to specify a revision limit if you don't want to. In my application, I only needed the most recent 5. To Dmitry, you're correct. I don't remember why, but I needed all the revisions for a while, then I limited the code to 5. I should have put the limit in the handleLogEntry method.
Thank you very much, I really appreciate. Time to study/fail/success :))
One more question, I am using svnAdresi = IniFonksiyon.iniSVNOkut(svnAdresi, "svnAdresi", "svnAdresiniAl"); Runtime cmdCalistir = Runtime.getRuntime(); try { Process islem = cmdCalistir.exec(svnAdresi); } catch (Exception e) { e.printStackTrace(); } to commit, Can I integrate the log with it ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.