I'm trying to modify this Mercurial extension to prompt the user to add a FogBugz case number to their commit message. Ideally, I'd like the user to just type in a number after being prompted and have it automatically appended to the commit message.
Here's what I've got so far:
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
What I haven't been able to find is a way to edit the commit message. tip.description
appears to be readonly, and I haven't seen anything in the documentation or examples that would let me modify it. The only references I've seen to editing commit messages have to do with patches and the Mq extension, and it doesn't seem like that can help here.
Any ideas as to how I could set the commit message?