Commit be95566d authored by Steve Borho's avatar Steve Borho
Browse files

revset: initial integration of revset into workbench

parent 604d5750f643
......@@ -10,10 +10,17 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
from tortoisehg.hgqt.i18n import _
from tortoisehg.hgqt import revset
class RepoFilterBar(QToolBar):
"""Toolbar for RepoWidget to filter changesets"""
revisionSet = pyqtSignal(object)
clearSet = pyqtSignal()
showMessage = pyqtSignal(QString)
progress = pyqtSignal(QString, object, QString, QString, object)
branchChanged = pyqtSignal(unicode, bool)
"""Emitted (branch, allparents) when branch selection changed"""
......@@ -22,12 +29,73 @@ class RepoFilterBar(QToolBar):
self.layout().setContentsMargins(0, 0, 0, 0)
self._repo = repo
self.addWidget(QLineEdit(text='### placeholder for revsets ###',
enabled=False))
self.entrydlg = revset.RevisionSetQuery(repo, self)
self.entrydlg.progress.connect(self.progress)
self.entrydlg.showMessage.connect(self.showMessage)
self.entrydlg.queryIssued.connect(self.dialogQuery)
self.entrydlg.hide()
self.clear = QPushButton(_('clear'))
self.addWidget(self.clear)
self.editor = QPushButton(_('editor'))
self.editor.clicked.connect(self.openEditor)
self.addWidget(self.editor)
s = QSettings()
self.entrydlg.restoreGeometry(s.value('revset/geom').toByteArray())
self.revsethist = list(s.value('revset-queries').toStringList())
self.revsetle = le = QLineEdit()
le.setCompleter(QCompleter(self.revsethist))
le.returnPressed.connect(self.returnPressed)
# Requires Qt 4.7
#self.revsetle.setPlaceholderText('### revision set query ###')
self.addWidget(le)
self.clear.clicked.connect(le.clear)
self.clear.clicked.connect(self.clearSet)
self.store = store = QPushButton(_('store'))
store.clicked.connect(self.saveQuery)
le.textChanged.connect(lambda t: store.setEnabled(False))
store.setEnabled(False)
self.addWidget(store)
self._initbranchfilter()
self.refresh()
def openEditor(self):
query = self.revsetle.text().simplified()
self.entrydlg.entry.setText(query)
self.entrydlg.entry.setCursorPosition(0, len(query))
self.entrydlg.entry.setFocus()
self.entrydlg.setShown(True)
def dialogQuery(self, query, revset):
self.revsetle.setText(query)
self.store.setEnabled(True)
self.revisionSet.emit(revset)
def returnPressed(self):
'Return pressed on revset line entry, forward to dialog'
query = self.revsetle.text().simplified()
if query:
self.entrydlg.entry.setText(query)
self.entrydlg.runQuery()
def saveQuery(self):
query = self.revsetle.text()
if query in self.revsethist:
self.revsethist.remove(query)
self.revsethist.insert(0, query)
self.revsetle.setCompleter(QCompleter(self.revsethist))
self.store.setEnabled(False)
self.showMessage.emit(_('Revision set query saved'))
def storeConfigs(self, s):
s.setValue('revset/geom', self.entrydlg.saveGeometry())
s.setValue('revset-queries', self.revsethist)
def _initbranchfilter(self):
self._branchLabel = QToolButton(
text=_('Branch'), popupMode=QToolButton.InstantPopup,
......
......@@ -75,6 +75,10 @@ class RepoWidget(QWidget):
self.filterbar = RepoFilterBar(self.repo)
self.filterbar.branchChanged.connect(self.setBranch)
self.filterbar.progress.connect(self.progress)
self.filterbar.showMessage.connect(self.showMessage)
self.filterbar.revisionSet.connect(self.setRevisionSet)
self.filterbar.clearSet.connect(self.clearSet)
self.layout().addWidget(self.filterbar)
self.layout().addWidget(self.repotabs_splitter)
......@@ -202,10 +206,18 @@ class RepoWidget(QWidget):
sw.showMessage.connect(self.showMessage)
return SharedWidget(sw)
def setOutgoingNodes(self, nodes):
def clearSet(self):
self.repomodel.revset = set()
self.refresh()
def setRevisionSet(self, nodes):
self.repomodel.revset = [self.repo[n].node() for n in nodes]
self.refresh()
def setOutgoingNodes(self, nodes):
self.filterbar.revsetle.setText('outgoing()')
self.setRevisionSet(nodes)
def createGrepWidget(self):
upats = {}
gw = SearchWidget(upats, self.repo, self)
......@@ -549,6 +561,7 @@ class RepoWidget(QWidget):
self.revDetailsWidget.storeSettings()
s = QSettings()
self.commitDemand.forward('storeConfigs', s)
self.filterbar.storeConfigs(s)
return True
def incoming(self):
......
......@@ -204,9 +204,6 @@ class RevisionSetQuery(QDialog):
self.stbar.addPermanentWidget(helpLabel)
layout.addWidget(self.stbar, 0)
s = QSettings()
self.restoreGeometry(s.value('revset/geom').toByteArray())
def runQuery(self):
text = hglib.fromunicode(self.entry.text())
self.entry.setEnabled(False)
......@@ -306,9 +303,7 @@ class RevisionSetQuery(QDialog):
super(RevisionSetQuery, self).keyPressEvent(event)
def accept(self):
s = QSettings()
s.setValue('revset/geom', self.saveGeometry())
super(RevisionSetQuery, self).accept()
self.hide()
def reject(self):
self.accept()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment