メモ。
本家資料よりも id:flying-foozy さんのスライドのほうがわかりやすいかも。
MercurialApi - Mercurial
How to write extension for Mercurial
from mercurial import ui from mercurial import hg from mercurial import cmdutil, patch u = ui.ui() repo = hg.repository(u, '.') for idx in repo: ctx = repo[idx] for filename in ctx: print '----%s----' % filename fctx = ctx[filename] print fctx.data()
リポジトリのディレクトリ内で実行してみると、リポジトリ内のファイルの内容が表示される。
$ python diff.py
----test.txt----
hoge
テスト
fuga
----diff.py----
from mercurial import ui
from mercurial import hg
from mercurial import cmdutil, patch
u = ui.ui()
repo = hg.repository(u, '.')
for idx in repo:
ctx = repo[idx]
for filename in ctx:
print '----%s----' % filename
fctx = ctx[filename]
print fctx.data()
----hoge/touch----
foo aaa.txt
----test.txt----
hoge
テスト
fuga