2012-01-10 14 views
6

Node.js用に書かれたライブラリを探しています Webアプリケーション で管理しているローカルリポジトリをMercurial HGで管理することができます。ローカルリポジトリ用Node.jsのMercurial HGライブラリ

誰かがそのようなものを実装しましたか?

+1

それはhttp://search.npmjs.org/ではないか、おそらくそれをhttps://github.com/joyent/node/wiki/modules場合存在しない(公開されている) –

答えて

7

私はそのようなライブラリについて聞いたことがありません。それはour mailinglistで発表されていません。 Mercurial用の安定したAPIはcommand lineなので、hgを直接起動して出力を解析することをお勧めします。スクリーンスクレイプが容易になるように設計されており、さらにtemplatesを使用してカスタマイズすることができます。

+1

コマンドサーバーを使用すると、hgの起動時のオーバーヘッドを避けることができますが、少し時間がかかります。 –

+0

私はそれについて考えましたが、最終的な解決策です。答えをありがとう。 – mrzepinski

+0

答えが役に立った(陰性だと思った)場合は、アップフォートして受け入れてください。 –

6

私は正確にこの理由のためにnode-hgと呼ばれるnpmで利用可能なモジュールを作成しました。

Command Serverのラッパーで、stdinでコマンドを発行し、出力をstdoutに解析します。ここで

は、それがどのように動作するかの例です:

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); 
      }); 
     }); 
    }); 
}); 
関連する問題