Mercurial API を使用して、特定の変更セットのリポジトリへの変更を取得する
-
23-09-2019 - |
質問
Mercurial API を使用して、各変更セットのリポジトリに加えられた変更を確認するにはどうすればよいですか?特定のリビジョンに関連するファイルのリストを取得することはできますが、そのファイルに何が起こったのかを知る方法がわかりません。
変更セット内の各ファイルに関する次の質問にどう答えればよいでしょうか。
- 追加されたんですか?
- 削除されたのでしょうか?
- 改造されたのでしょうか?
ファイル コンテキストにこれを知らせる属性はありますか (もしあれば、見つけることができません)、それとも他の方法でこれを理解する方法はありますか?
これが私のコードです:
def index(request):
u = ui.ui()
repo = hg.repository(ui.ui(), '/path/to/repo')
changes = repo.changelog
changesets = []
for change in changes:
ctx = repo.changectx(change)
fileCtxs = []
for aFile in ctx.files():
if aFile in ctx:
for status in repo.status(None, ctx.node()):
# I'm hoping this could return A, M, D, ? etc
fileCtxs.append(status)
changeset = {
'files':ctx.files(),
'rev':str(ctx.rev()),
'desc':ctx.description(),
'user':ctx.user(),
'filectxs':fileCtxs,
}
changesets.append(changeset)
c = Context({
'changesets': changesets,
})
tmplt = loader.get_template('web/index.html')
return HttpResponse(tmplt.render(c))
解決
localrepo.status()
引数(node1
とnode2
)としてコンテキストをとることができます。
を参照してください。 http://hg.intevation.org /mercurial/crew/file/6505773080e4/mercurial/localrepo.py#l973する
所属していません StackOverflow