We are trying to write a mercurial pre-commit hook which should work with both commandline and TortoiseHg.
The idea of the hook is to connect to JIRA and get the list of activities assigned to the developer, and show the activities in a list from which the developer can choose one. The JIRA ID and summary will then be put in the commit comment.
Now, we have the basic parts of most of the functionality figured out, but are missing a way to show a list. We've tried to show a basic QtWidget with input field and a button (using PyQt4), and using the command line the window appears, we can enter text and press the button to print the text (or send it out with ui.status).
In TortoiseHg (version 2.7.1) it doesn't work that well. The hook fires and the window opens but it appears as if control is not properly passed on. The input field on the new window doesn't get active, we can't see when we type text, but when clicking the button the contents are printed to ui.status. More worringly is that TortoiseHg stops updating the graphics, so when the window is closed there is a blank spot in the TortoiseHg window and THG doesn't respond to any input. We have to use the process explorer to shoot it down.
Any hints as to how to write a hook which opens a window which we can interact with under TortoiseHg?
Hook definition:
pre-commit = python:e:\repos\SCM-TOOLS\hg-hooks\user.py:hook
Python code:
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class AppForm(QMainWindow):
def __init__(self, ui, parent=None):
QMainWindow.__init__(self, parent)
self.u = ui
self.create_main_frame()
def create_main_frame(self):
page = QWidget()
self.button = QPushButton('Test', page)
self.edit1 = QLineEdit()
vbox1 = QVBoxLayout()
vbox1.addWidget(self.edit1)
vbox1.addWidget(self.button)
page.setLayout(vbox1)
self.setCentralWidget(page)
self.connect(self.button, SIGNAL("clicked()"), self.clicked)
def clicked(self):
self.u.status (str(self.edit1.text()))
def hook(ui, repo, **kwargs):
app = QApplication(sys.argv)
form = AppForm(ui)
form.show()
app.exec_()
sys.exit(1)
Edit: In addition to this working in TortoiseHg and from the commandline it should also work in Eclipse and IntelliJ, therefore the suggested TortoiseHg plugins are not a full solution.