对Java API水银? [英] Mercurial API for Java?

查看:114
本文介绍了对Java API水银?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个简单的API从Java访问的Mercurial库?

Is there a plain API to access Mercurial repositories from Java?

有用于NetBeans和Eclipse插件,但不像他们颠覆的同行,他们不使用常见的低级别的库,但把自己的包装,以调出该水银二进制文件。调用二进制会好起来的(现在),但似乎很难用在独立应用这些插件(他​​们被建为IDE之外)。

There are plugins for Netbeans and Eclipse, but unlike their Subversion counterparts, they do not use a common lower-level library but bring their own wrappers to call out to the Mercurial binary. Calling the binary would be okay (for now), but it seems very difficult to use those plugins in standalone applications (outside of the IDE they were built for).

有也HgKit,但是这是非常pre-α

There is also HgKit, but that is very pre-alpha.

推荐答案

一个新的选项是 JavaHg ,它给你一个高层次的Java API。该单元测试给出了如何一个很好的例子它与它编程(如JavaHg 0.1的):

A new option is JavaHg, which gives you a high-level Java API. The unit tests give a good example of how it is to program with it (as of JavaHg 0.1):

public void commitTest() throws IOException {
    Repository repo = getTestRepository();
    writeFile("x", "abc");

    CommitCommand commit = CommitCommand.on(repo);
    StatusCommand status = StatusCommand.on(repo);

    List<StatusLine> statusLines = status.lines();
    Assert.assertEquals(1, statusLines.size());
    Assert.assertEquals(StatusLine.Type.UNKNOWN, statusLines.get(0).getType());

    AddCommand.on(repo).execute();
    statusLines = status.lines();
    Assert.assertEquals(1, statusLines.size());
    Assert.assertEquals(StatusLine.Type.ADDED, statusLines.get(0).getType());

    commit.message("Add a file").user("Martin Geisler");
    Changeset cset = commit.execute();
    Assert.assertEquals("Martin Geisler", cset.getUser());
    statusLines = status.lines();
    Assert.assertEquals(0, statusLines.size());
}

这与1.9和更高版本的的Mercurial命令服务器 present交互。这意味着,将有一个持续的过程水银围绕接受多个命令,所以你的避免启动开销通常与发射水银有关。我们期望它在一个未来版本MercurialEclipse的使用。 (我JavaHg的作者之一。)

It interacts with the Mercurial command server present in version 1.9 and later. This means that there will be a persistent Mercurial process around that accepts multiple commands and so you avoid the startup overhead normally associated with launching Mercurial. We expect that it will be used in a coming version of MercurialEclipse. (I'm one of the authors of JavaHg.)

这篇关于对Java API水银?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆