我如何使用 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
关于python - 使用 Mercurial API 获取给定变更集的存储库变更,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2352129/