用于本地存储库的Node.js的Mercurial HG库

我正在寻找为Node.js编写的库,我可以使用它来从Web应用程序pipe理在Mercurial HG中创build的本地存储库。

任何人都执行类似的东西?

我从来没有听说过这样的图书馆 – 它没有在我们的邮件列表上公布。 Mercurial的稳定API是命令行 ,所以我build议直接启动hg并parsing输出。 它的devise是很容易的屏幕刮,你可以通过使用模板进一步定制。

我已经在npm上创build了一个名为node-hg的模块,正是出于这个原因。

它是Command Server的一个包装器,它通过stdin发出命令并parsingstdout

这是一个如何工作的例子:

 var path = require("path"); var hg = require("hg"); // Clone into "../example-node-hg" var destPath = path.resolve(path.join(process.cwd(), "..", "my-node-hg")); hg.clone("http://bitbucket.org/jgable/node-hg", destPath, function(err, output) { if(err) { throw err; } output.forEach(function(line) { console.log(line.body); }); // Add some files to the repo with fs.writeFile, omitted for brevity hg.add(destPath, ["someFile1.txt", "someFile2.txt"], function(err, output) { if(err) { throw err; } output.forEach(function(line) { console.log(line.body); }); var commitOpts = { "-m": "Doing the needful" }; // Commit our new files hg.commit(destPath, commitOpts, function(err, output) { if(err) { throw err; } output.forEach(function(line) { console.log(line.body); }); }); }); });