我试图修改this Mercurial extension以提示用户添加一个FogBugz案例编号到他们的提交消息。理想情况下,我希望用户在被提示后输入一个数字,并自动附加到提交消息中。如何设置或修改来自mercurial extension的提交消息?
这里是我到目前为止有:
def pretxncommit(ui, repo, **kwargs):
tip = repo.changectx(repo.changelog.tip())
if not RE_CASE.search(tip.description()) and len(tip.parents()) < 2:
casenumResponse = ui.prompt('*** Please specify a case number, x to abort, or hit enter to ignore:', '')
casenum = RE_CASENUM.search(casenumResponse)
if casenum:
# this doesn't work!
# tip.description(tip.description() + ' (Case ' + casenum.group(0) + ')')
return True
elif (casenumResponse == 'x'):
ui.warn('*** User aborted\n')
return True
return True
return False
我一直没能找到是编辑提交信息的方式。 tip.description
似乎是只读的,我还没有看到任何可以让我修改的文档或示例。我见过的编辑提交消息的唯一参考文件与修补程序和Mq扩展名有关,它似乎并不能在这里提供帮助。
关于如何设置提交消息的任何想法?
我能做到什么,我需要使用extensions.wrapcommand。看看我的回答:) –