我試圖修改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。看看我的回答:) –