Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# mq.py - TortoiseHg MQ widget## Copyright 2011 Steve Borho <steve@borho.org>## This software may be used and distributed according to the terms of the# GNU General Public License version 2 or any later version.importosimportrefromPyQt4.QtCoreimport*fromPyQt4.QtGuiimport*frommercurialimporthg,ui,url,util,errorfrommercurialimportmergeasmergemodfromhgextimportmqasmqmodfromtortoisehg.utilimporthglib,patchctxfromtortoisehg.hgqt.i18nimport_fromtortoisehg.hgqtimportqtlib,cmdui,rejects,commit,shelve,qscilibclassMQWidget(QWidget):showMessage=pyqtSignal(unicode)output=pyqtSignal(QString,QString)progress=pyqtSignal(QString,object,QString,QString,object)makeLogVisible=pyqtSignal(bool)def__init__(self,repo,parent,**opts):QWidget.__init__(self,parent)self.repo=repoself.opts=optsself.refreshing=Falselayout=QVBoxLayout()layout.setSpacing(0)self.setLayout(layout)# top toolbartbarhbox=QHBoxLayout()tbarhbox.setSpacing(5)self.layout().addLayout(tbarhbox,0)self.queueCombo=QComboBox()self.optionsBtn=QPushButton(_('Options'))self.msgHistoryCombo=PatchMessageCombo(self)tbarhbox.addWidget(self.queueCombo)tbarhbox.addWidget(self.optionsBtn)tbarhbox.addWidget(self.msgHistoryCombo,1)# main area consists of a three-way horizontal splitterself.splitter=splitter=QSplitter()self.layout().addWidget(splitter,1)splitter.setOrientation(Qt.Horizontal)splitter.setChildrenCollapsible(True)splitter.setObjectName('splitter')self.queueFrame=QFrame(splitter)self.messageFrame=QFrame(splitter)self.fileListFrame=QFrame(splitter)# Patch Queue Framelayout=QVBoxLayout()layout.setContentsMargins(0,0,0,0)self.queueFrame.setLayout(layout)qtbarhbox=QHBoxLayout()qtbarhbox.setSpacing(2)layout.addLayout(qtbarhbox,0)qtbarhbox.setContentsMargins(0,0,0,0)self.qpushAllBtn=tb=QToolButton()#tb.setIcon(qtlib.geticon('qpush'))tb.setToolTip(_('Apply all patches'))self.qpushBtn=tb=QToolButton()tb.setIcon(qtlib.geticon('qpush'))tb.setToolTip(_('Apply one patch'))self.setGuardsBtn=tb=QToolButton()#tb.setIcon(qtlib.geticon('qpush'))tb.setToolTip(_('Configure guards for selected patch'))self.qpushMoveBtn=tb=QToolButton()#tb.setIcon(qtlib.geticon('qpush'))tb.setToolTip(_('Apply selected patch next (change queue order)'))self.qdeleteBtn=tb=QToolButton()tb.setIcon(qtlib.geticon('filedelete'))tb.setToolTip(_('Delete selected patches'))self.qpopBtn=tb=QToolButton()tb.setIcon(qtlib.geticon('qpop'))tb.setToolTip(_('Unapply one patch'))self.qpopAllBtn=tb=QToolButton()#tb.setIcon(qtlib.geticon('qpop'))tb.setToolTip(_('Unapply all patches'))qtbarhbox.addWidget(self.qpushAllBtn)qtbarhbox.addWidget(self.qpushBtn)qtbarhbox.addStretch(1)qtbarhbox.addWidget(self.setGuardsBtn)qtbarhbox.addWidget(self.qpushMoveBtn)qtbarhbox.addWidget(self.qdeleteBtn)qtbarhbox.addStretch(1)qtbarhbox.addWidget(self.qpopBtn)qtbarhbox.addWidget(self.qpopAllBtn)self.queueListWidget=QListWidget(self)layout.addWidget(self.queueListWidget,1)self.guardSelBtn=QPushButton()layout.addWidget(self.guardSelBtn,0)self.revisionOrCommitBtn=QPushButton()layout.addWidget(self.revisionOrCommitBtn,0)# Message Framelayout=QVBoxLayout()layout.setContentsMargins(0,0,0,0)self.messageFrame.setLayout(layout)mtbarhbox=QHBoxLayout()mtbarhbox.setSpacing(5)layout.addLayout(mtbarhbox,0)mtbarhbox.setContentsMargins(0,0,0,0)self.newCheckBox=QCheckBox(_('New Patch'))self.patchNameLE=QLineEdit()mtbarhbox.addWidget(self.newCheckBox)mtbarhbox.addWidget(self.patchNameLE,1)self.messageEditor=commit.MessageEntry(self)self.messageEditor.installEventFilter(qscilib.KeyPressInterceptor(self))self.messageEditor.refresh(repo)layout.addWidget(self.messageEditor,1)qrefhbox=QHBoxLayout()layout.addLayout(qrefhbox,0)qrefhbox.setContentsMargins(0,0,0,0)self.shelveBtn=QPushButton(_('Shelve'))self.qnewOrRefreshBtn=QPushButton(_('QRefresh'))qrefhbox.addStretch(1)qrefhbox.addWidget(self.shelveBtn)qrefhbox.addWidget(self.qnewOrRefreshBtn)# File List Framelayout=QVBoxLayout()layout.setContentsMargins(0,0,0,0)self.fileListFrame.setLayout(layout)self.fileListWidget=QListWidget(self)layout.addWidget(self.fileListWidget,0)# Command runner and connections...self.cmd=cmdui.Runner(_('Patch Queue'),parent!=None,self)self.cmd.output.connect(self.output)self.cmd.makeLogVisible.connect(self.makeLogVisible)self.cmd.progress.connect(self.progress)self.cmd.commandFinished.connect(self.onCommandFinished)self.shelveBtn.clicked.connect(self.launchShelveTool)self.optionsBtn.clicked.connect(self.launchOptionsDialog)self.revisionOrCommitBtn.clicked.connect(self.qinitOrCommit)self.msgHistoryCombo.activated.connect(self.onMessageSelected)self.queueListWidget.currentRowChanged.connect(self.onPatchSelected)self.queueListWidget.itemActivated.connect(self.onGotoPatch)self.queueListWidget.itemChanged.connect(self.onRenamePatch)self.qpushAllBtn.clicked.connect(self.onPushAll) self.qpushBtn.clicked.connect(self.onPush)
self.qpopAllBtn.clicked.connect(self.onPopAll)
self.qpopBtn.clicked.connect(self.onPop)
+ self.qdeleteBtn.clicked.connect(self.onDelete) self.repo.configChanged.connect(self.onConfigChanged)
self.repo.repositoryChanged.connect(self.onRepositoryChanged)
self.setAcceptDrops(True)ifhasattr(self.patchNameLE,'setPlaceholderText'):# Qt >= 4.7 self.patchNameLE.setPlaceholderText('### patch name ###')ifparent:self.layout().setContentsMargins(2,2,2,2)else:self.layout().setContentsMargins(0,0,0,0)self.setWindowTitle(_('TortoiseHg Patch Queue'))self.statusbar=cmdui.ThgStatusBar(self)self.layout().addWidget(self.statusbar)self.progress.connect(self.statusbar.progress)self.showMessage.connect(self.statusbar.showMessage)QShortcut(QKeySequence.Refresh,self,self.reload)self.resize(850,550)self.loadConfigs()QTimer.singleShot(0,self.reload)@pyqtSlot()defonConfigChanged(self):'Repository is reporting its config files have changed'self.messageEditor.refresh(self.repo)@pyqtSlot()defonRepositoryChanged(self):'Repository is reporting its changelog has changed'self.reload()@pyqtSlot(int)defonCommandFinished(self,ret):self.repo.decrementBusyCount()ifretisnot0:pass# TODO: look for reject notificationsself.reload()# TODO: probably redundant@pyqtSlot()defonPushAll(self):self.repo.incrementBusyCount()self.cmd.run(['qpush','-R',self.repo.root,'--all'])@pyqtSlot()defonPush(self):self.repo.incrementBusyCount()self.cmd.run(['qpush','-R',self.repo.root])@pyqtSlot()defonPopAll(self):self.repo.incrementBusyCount()self.cmd.run(['qpop','-R',self.repo.root,'--all'])@pyqtSlot()defonPop(self): self.repo.incrementBusyCount()
self.cmd.run(['qpop', '-R', self.repo.root])
+ @pyqtSlot()+ def onDelete(self):+ from tortoisehg.hgqt import qdelete+ patch = self.queueListWidget.currentItem()._thgpatch+ dlg = qdelete.QDeleteDialog(self.repo, [patch], self)+ dlg.finished.connect(dlg.deleteLater)+ if dlg.exec_() == QDialog.Accepted:+ self.reload()+ @pyqtSlot(QListWidgetItem)
def onGotoPatch(self, item):
'Patch has been activated (return), issue qgoto'
self.repo.incrementBusyCount()self.cmd.run(['qgoto','-R',self.repo.root,item._thgpatch])@pyqtSlot(QListWidgetItem)defonRenamePatch(self,item):'Patch has been renamed, issue qrename'self.repo.incrementBusyCount()self.cmd.run(['qrename','-R',self.repo.root,item._thgpatch,hglib.fromunicode(item.text())])@pyqtSlot(int)defonPatchSelected(self,row):'Patch has been selected, update buttons'ifself.refreshing:return if row >= 0:
patch = self.queueListWidget.item(row)._thgpatch
applied = set([p.name for p in self.repo.mq.applied])
- self.qdeleteBtn.setEnabled(True)
+ self.qdeleteBtn.setEnabled(patch not in applied)
self.qpushMoveBtn.setEnabled(patch not in applied)
self.setGuardsBtn.setEnabled(True)
else:
self.qdeleteBtn.setEnabled(False)self.qpushMoveBtn.setEnabled(False)self.setGuardsBtn.setEnabled(False)@pyqtSlot(int)defonMessageSelected(self,row):ifself.messageEditor.text()andself.messageEditor.isModified():d=QMessageBox.question(self,_('Confirm Discard Message'),_('Discard current commit message?'),QMessageBox.Ok|QMessageBox.Cancel)ifd!=QMessageBox.Ok:returnself.messageEditor.setText(self.messages[row][1])lines=self.messageEditor.lines()iflines:lines-=1pos=self.messageEditor.lineLength(lines)self.messageEditor.setCursorPosition(lines,pos)self.messageEditor.ensureLineVisible(lines)hs=self.messageEditor.horizontalScrollBar()hs.setSliderPosition(0)self.messageEditor.setModified(False)self.messageEditor.setFocus()@pyqtSlot()defqinitOrCommit(self):ifos.path.isdir(self.repo.mq.join('.hg')):dlg=commit.CommitDialog([],dict(root=self.repo.mq.path),self)dlg.finished.connect(dlg.deleteLater)dlg.exec_()self.reload()else:self.repo.incrementBusyCount()self.cmd.run(['qinit','-c','-R',self.repo.root])@pyqtSlot()deflaunchShelveTool(self):dlg=shelve.ShelveDialog(self.repo,self)dlg.finished.connect(dlg.deleteLater)dlg.exec_()self.reload()@pyqtSlot()deflaunchOptionsDialog(self):dlg=OptionsDialog(self)dlg.finished.connect(dlg.deleteLater)dlg.setWindowFlags(Qt.Sheet)dlg.setWindowModality(Qt.WindowModal)ifdlg.exec_()==QDialog.Accepted:self.opts.update(dlg.outopts)defreload(self):self.refreshing=Truetry:try:self._reload()exceptException,e:self.showMessage.emit(hglib.tounicode(str(e)))finally:self.refreshing=Falsedef_reload(self):ui,repo=self.repo.ui,self.repoself.queueCombo.clear()self.queueListWidget.clear()self.fileListWidget.clear()ui.pushbuffer()mqmod.qqueue(ui,repo,list=True)out=ui.popbuffer()activestr=' (active)'# TODO: not locale safefori,qnameinenumerate(out.splitlines()):ifqname.endswith(activestr):current=iqname=qname[:-len(activestr)]self.queueCombo.addItem(hglib.tounicode(qname))self.queueCombo.setCurrentIndex(current)# TODO: maintain current selectionapplied=set([p.nameforpinrepo.mq.applied])self.allguards=set()items=[]foridx,patchinenumerate(repo.mq.series):item=QListWidgetItem(hglib.tounicode(patch))ifpatchinapplied:# appliedf=item.font()f.setBold(True)item.setFont(f)elifnotrepo.mq.pushable(idx)[0]:# guardedf=item.font()f.setItalic(True)item.setFont(f)patchguards=repo.mq.series_guards[idx]ifpatchguards:forguardinpatchguards:self.allguards.add(guard[1:])uguards=hglib.tounicode(', '.join(patchguards))else:uguards=_('no guards')uname=hglib.tounicode(patch)item._thgpatch=patchitem.setToolTip(u'%s: %s'%(uname,uguards))item.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEditable|Qt.ItemIsEnabled)items.append(item)foriteminreversed(items):self.queueListWidget.addItem(item)forguardinrepo.mq.active_guards:self.allguards.add(guard)self.refreshSelectedGuards()self.messages=[]forpatchinrepo.mq.series:ctx=repo.changectx(patch)msg=ctx.description()ifmsg:self.messages.append((patch,msg))self.msgHistoryCombo.reset(self.messages)ifos.path.isdir(self.repo.mq.join('.hg')):self.revisionOrCommitBtn.setText(_('Commit Queue'))else:self.revisionOrCommitBtn.setText(_('Revision Queue'))self.qpushAllBtn.setEnabled(bool(repo.thgmqunappliedpatches))self.qpushBtn.setEnabled(bool(repo.thgmqunappliedpatches))self.qpushMoveBtn.setEnabled(False)self.qdeleteBtn.setEnabled(False)self.setGuardsBtn.setEnabled(False)self.qpopBtn.setEnabled(bool(applied))self.qpopAllBtn.setEnabled(bool(applied))# refresh self.messageEditor with qtip description, if not new# set self.patchNameLE to qtip patch name, if not new# refresh self.qnewOrRefreshBtn# refresh self.fileListWidgetdefrefreshSelectedGuards(self):total=len(self.allguards)count=len(self.repo.mq.active_guards)oldmenu=self.guardSelBtn.menu()ifoldmenu:oldmenu.setParent(None)menu=QMenu(self)forguardinself.allguards:a=menu.addAction(hglib.tounicode(guard))a.setCheckable(True)a.setChecked(guardinself.repo.mq.active_guards)a.triggered.connect(self.onGuardSelectionChange)self.guardSelBtn.setMenu(menu)self.guardSelBtn.setText(_('Guards: %d/%d')%(count,total))defonGuardSelectionChange(self,isChecked):guard=hglib.fromunicode(self.sender().text())newguards=self.repo.mq.active_guards[:]ifisChecked:newguards.append(guard)elifguardinnewguards:newguards.remove(guard)cmdline=['qselect','-R',self.repo.root]cmdline+=newguardsor['--none']self.cmd.run(cmdline)# Capture drop events, try to import into current patch queuedefdragEnterEvent(self,event):event.acceptProposedAction()defdragMoveEvent(self,event):event.acceptProposedAction()defdropEvent(self,event):paths=[unicode(u.toLocalFile())foruinevent.mimeData().urls()]filepaths=[pforpinpathsifos.path.isfile(p)]iffilepaths:event.setDropAction(Qt.CopyAction)event.accept()else:super(MQWidget,self).dropEvent(event)returndlg=thgimport.ImportDialog(repo=self.repo,parent=self)# TODO: send flag to dialog indicating this is a qimport (alias?)dlg.finished.connect(dlg.deleteLater)dlg.setfilepaths(filepaths)dlg.exec_()# End drop eventsdefloadConfigs(self):'Load history, etc, from QSettings instance's=QSettings()self.splitter.restoreState(s.value('mq/splitter').toByteArray())userhist=s.value('commit/userhist').toStringList()self.opts['userhist']=[hglib.fromunicode(u)foruinuserhistifu]ifnotself.parent():self.restoreGeometry(s.value('mq/geom').toByteArray())defstoreConfigs(self):'Save history, etc, in QSettings instance's=QSettings()s.setValue('mq/splitter',self.splitter.saveState())ifnotself.parent():s.setValue('mq/geom',self.saveGeometry())defcanExit(self):self.storeConfigs()returnnotself.cmd.core.running()defkeyPressEvent(self,event):ifevent.key()==Qt.Key_Escape:ifself.cmd.core.running():self.cmd.cancel()elifnotself.parent()andself.canExit():self.close()else:returnsuper(MQWidget,self).keyPressEvent(event)classPatchMessageCombo(QComboBox):def__init__(self,parent):super(PatchMessageCombo,self).__init__(parent)self.reset([])defreset(self,msglist):self.clear()self.addItem(_('Patch commit messages...'))self.loaded=Falseself.msglist=msglistdefshowPopup(self):ifnotself.loadedandself.msglist:self.clear()forpatch,messageinself.msglist:sum=message.split('\n',1)[0][:70]self.addItem(hglib.tounicode('%s: %s'%(patch,sum)))self.loaded=Trueifself.loaded:super(PatchMessageCombo,self).showPopup()classOptionsDialog(QDialog):'Utility dialog for configuring uncommon options'def__init__(self,parent):QDialog.__init__(self,parent)self.setWindowTitle('MQ options')layout=QFormLayout()self.setLayout(layout)self.gitcb=QCheckBox(_('Use git extended diff format'))layout.addRow(self.gitcb,None)self.forcecb=QCheckBox(_('Force push or pop'))layout.addRow(self.forcecb,None)self.exactcb=QCheckBox(_('Apply patch to its recorded parent'))layout.addRow(self.exactcb,None)self.currentdatecb=QCheckBox(_('Update date field with current date'))layout.addRow(self.currentdatecb,None)self.datele=QLineEdit()layout.addRow(QLabel(_('Specify an explicit date:')),self.datele)self.currentusercb=QCheckBox(_('Update author field with current user'))layout.addRow(self.currentusercb,None)self.userle=QLineEdit()layout.addRow(QLabel(_('Specify an explicit author:')),self.userle)self.currentdatecb.toggled.connect(self.datele.setDisabled)self.currentusercb.toggled.connect(self.userle.setDisabled)self.gitcb.setChecked(parent.opts.get('git',False))self.forcecb.setChecked(parent.opts.get('force',False))self.exactcb.setChecked(parent.opts.get('exact',False))self.currentdatecb.setChecked(parent.opts.get('currentdate',False))self.currentusercb.setChecked(parent.opts.get('currentuser',False))self.datele.setText(hglib.tounicode(parent.opts.get('date','')))self.userle.setText(hglib.tounicode(parent.opts.get('user','')))BB=QDialogButtonBoxbb=QDialogButtonBox(BB.Ok|BB.Cancel)bb.accepted.connect(self.accept)bb.rejected.connect(self.reject)self.bb=bblayout.addWidget(bb)defaccept(self):outopts={}outopts['git']=self.gitcb.isChecked()outopts['force']=self.forcecb.isChecked()outopts['exact']=self.exactcb.isChecked()outopts['currentdate']=self.currentdatecb.isChecked()outopts['currentuser']=self.currentusercb.isChecked()ifself.currentdatecb.isChecked():outopts['date']=''else:outopts['date']=hglib.fromunicode(self.datele.text())ifself.currentusercb.isChecked():outopts['user']=''else:outopts['user']=hglib.fromunicode(self.userle.text())self.outopts=outoptsQDialog.accept(self)defrun(ui,*pats,**opts):fromtortoisehg.utilimportpathsfromtortoisehg.hgqtimportthgreporepo=thgrepo.repository(ui,path=paths.find_root())returnMQWidget(repo,None,**opts)
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.