SVN提交日志问题

时间:2012-07-02 16:03:10

标签: java eclipse svn logging svnkit

我目前正在开展一个关于计算的项目。我已完成项目的主要部分,还将SVN Commit功能集成到我的代码中(使用.ini文件读取特定地址等)

我可以轻松提交文件,我正在尝试的是我想实现我的控制台的实时日志。有没有办法将日志实现到控制台?不是一般日志,而是提交日志应该是实时的。

  • 我正在使用eclipse for mac,我听说过SVNKit,但我对SVN的态度很差。

提前感谢您提供任何信息

---编辑---

这是从.ini文件

读取svn命令的代码
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 
        {

        }

    }

这就是.ini包含的内容

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

这就是我所说的

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

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

1 个答案:

答案 0 :(得分:2)

如果我正确理解您的问题,您希望将Subversion提交日志读入您的控制台应用程序。

最简单的方法是使用SVNKit

我是这样做的。

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 - 指向特定目录或模块的字符串
  • latestRevision - 来自Subversion的最大版本号。在log方法调用中放置latestRevision第二个以最近的顺序返回日志记录。

如果您希望按顺序排列日志记录,从1到latestRevision,那么1L将排在第二位,而latestRevision将排在第三位。

  • repository - 您已经过身份验证的Subversion存储库。

这是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);
        }
    }

}  
相关问题