java - SVN提交日志问题

标签 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();
    }

最佳答案

如果我正确理解你的问题,你想将 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();
  • 目录 - 指向特定目录或模块的字符串
  • latestRevision - Subversion 的最大修订版本号。将latestRevision 放在日志方法调用的第二个位置会按最新顺序返回日志记录。

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

  • 存储库 - 您已通过身份验证的 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);
        }
    }

}  

关于java - SVN提交日志问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11297205/

相关文章:

git - 使用快速导入/导出流的 SVN 到 Git

java - java中包含操作系统级命令的包有哪些?

java - Junit 用于无效验证方法

java - 异步 Lambda 代理集成

windows - Eclipse,导入项目但不复制

svn - 解决 svn "Two top-level reports with no target"的最佳方法

java - 文件读取器相对路径

java - 如果e(jx)clipse插件不起作用怎么办?

android - 安装新的 Android SDK 时遇到问题

eclipse PDT : put my workspace under htdocs or is there a "move files" build directive?